mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-12 19:18:42 +00:00
added starboard functionality (starboard/starstats)
added module to store/retrieve configuration (double and string values) replaced a few null values with optionals (emote loading) fixed creating channels on startup added delete message/get emote utility to bot service extended emote service to have utility methods to use emotes added reactions to message cache added empty message handling to post target service, in case the template evaluates to empty added ability to edit a message in a post target (standard message and embed) added principle of config listeners, so default config can be created, for example starboard thresholds added abstract reaction listeners for adding/removing/clearing fixed foreign keys between channel and server added emote utils to handle AEmote and Emotes renamed emotes to be camelCase, so they are easier to type
This commit is contained in:
@@ -39,16 +39,25 @@ public class MessageDeletedListener extends ListenerAdapter {
|
||||
@Autowired
|
||||
private PostTargetService postTargetService;
|
||||
|
||||
@Autowired
|
||||
private MessageDeletedListener self;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void onGuildMessageDelete(@Nonnull GuildMessageDeleteEvent event) {
|
||||
CachedMessage messageFromCache = null;
|
||||
try {
|
||||
messageFromCache = messageCache.getMessageFromCache(event.getGuild().getIdLong(), event.getChannel().getIdLong(), event.getMessageIdLong());
|
||||
} catch (ExecutionException | InterruptedException e) {
|
||||
log.warn("Failed to load message.", e);
|
||||
return;
|
||||
}
|
||||
messageCache.getMessageFromCache(event.getGuild().getIdLong(), event.getChannel().getIdLong(), event.getMessageIdLong())
|
||||
.thenAccept(messageFromCache -> {
|
||||
try {
|
||||
self.logMessage(event, messageFromCache);
|
||||
} catch (Exception e) {
|
||||
log.error("Error when logging message deletion.", e);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void logMessage(@Nonnull GuildMessageDeleteEvent event, CachedMessage messageFromCache) {
|
||||
MessageDeletedLog logModel = (MessageDeletedLog) contextUtils.fromMessage(messageFromCache, MessageDeletedLog.class);
|
||||
logModel.setMessage(messageFromCache);
|
||||
String simpleMessageUpdatedMessage = templateService.renderTemplate(MESSAGE_DELETED_TEMPLATE, logModel);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.sheldan.abstracto.moderation.listener;
|
||||
|
||||
import dev.sheldan.abstracto.core.MessageTextUpdatedListener;
|
||||
import dev.sheldan.abstracto.core.listener.MessageTextUpdatedListener;
|
||||
import dev.sheldan.abstracto.core.models.CachedMessage;
|
||||
import dev.sheldan.abstracto.core.models.embed.MessageToSend;
|
||||
import dev.sheldan.abstracto.core.service.MessageCache;
|
||||
|
||||
Reference in New Issue
Block a user