use of stream.flarebot.flarebot.database.RedisMessage in project FlareBot by FlareBot.
the class ModlogEvents method onMessageDelete.
private void onMessageDelete(MessageDeleteEvent event, @Nonnull GuildWrapper wrapper) {
if (cannotHandle(wrapper, ModlogEvent.MESSAGE_DELETE))
return;
AuditLogEntry entry = event.getGuild().getAuditLogs().type(ActionType.MESSAGE_DELETE).complete().get(0);
if (entry.getUser().isBot())
return;
User responsible = null;
if (FlareBot.instance().getEvents().getRemovedByMeList().contains(event.getMessageIdLong())) {
FlareBot.instance().getEvents().getRemovedByMeList().remove(event.getMessageIdLong());
return;
}
if (!RedisController.exists(event.getMessageId()))
return;
RedisMessage deleted = GeneralUtils.toRedisMessage(RedisController.get(event.getMessageId()));
if (entry.getTargetId().equals(deleted.getAuthorID())) {
if (entry.getUser().isBot())
return;
responsible = entry.getUser();
}
User sender = GuildUtils.getUser(deleted.getAuthorID());
ModlogHandler.getInstance().postToModlog(wrapper, ModlogEvent.MESSAGE_DELETE, sender, (responsible != null ? new MessageEmbed.Field("Deleted By", MessageUtils.getUserAndId(responsible), true) : null), new MessageEmbed.Field("Message", FormatUtils.truncate(1024, deleted.getContent(), true), true), new MessageEmbed.Field("Channel", event.getTextChannel().getName() + " (" + deleted.getChannelID() + ")", true), new MessageEmbed.Field("Sent", FormatUtils.formatTime(Instant.ofEpochMilli(deleted.getTimestamp()).atZone(ZoneId.systemDefault()).toLocalDateTime()), true));
RedisController.del(event.getMessageId());
}
use of stream.flarebot.flarebot.database.RedisMessage in project FlareBot by FlareBot.
the class ModlogEvents method onMessageUpdate.
/*private void onGuildMessageReceived(GuildMessageReceivedEvent event, @Nonnull GuildWrapper wrapper) {
}*/
private void onMessageUpdate(MessageUpdateEvent event, @Nonnull GuildWrapper wrapper) {
if (cannotHandle(wrapper, ModlogEvent.MESSAGE_EDIT))
return;
if (event.getAuthor().isBot())
return;
if (!RedisController.exists(event.getMessageId()))
return;
RedisMessage old = GeneralUtils.toRedisMessage(RedisController.get(event.getMessageId()));
ModlogHandler.getInstance().postToModlog(wrapper, ModlogEvent.MESSAGE_EDIT, event.getAuthor(), new MessageEmbed.Field("Old Message", FormatUtils.truncate(1024, old.getContent(), true), false), new MessageEmbed.Field("New Message", FormatUtils.truncate(1024, event.getMessage().getContentDisplay(), true), false), new MessageEmbed.Field("Channel", event.getTextChannel().getName() + " (" + event.getTextChannel().getId() + ")", true));
RedisController.set(event.getMessageId(), GeneralUtils.getRedisMessageJson(event.getMessage()), "xx", "ex", 61200);
}
Aggregations