package cc.fascinated.bat.service; import cc.fascinated.bat.common.EmbedUtils; import cc.fascinated.bat.event.EventListener; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatUser; import cc.fascinated.bat.model.DiscordMessage; import lombok.NonNull; import lombok.extern.log4j.Log4j2; import net.dv8tion.jda.api.entities.Invite; import net.dv8tion.jda.api.events.channel.ChannelCreateEvent; import net.dv8tion.jda.api.events.channel.ChannelDeleteEvent; import net.dv8tion.jda.api.events.channel.update.*; import net.dv8tion.jda.api.events.emoji.EmojiAddedEvent; import net.dv8tion.jda.api.events.emoji.EmojiRemovedEvent; import net.dv8tion.jda.api.events.emoji.update.EmojiUpdateNameEvent; import net.dv8tion.jda.api.events.guild.GuildBanEvent; import net.dv8tion.jda.api.events.guild.GuildUnbanEvent; import net.dv8tion.jda.api.events.guild.invite.GuildInviteCreateEvent; import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent; import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent; import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleAddEvent; import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleRemoveEvent; import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateBoostTimeEvent; import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateNicknameEvent; import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateTimeOutEvent; import net.dv8tion.jda.api.events.guild.override.GenericPermissionOverrideEvent; import net.dv8tion.jda.api.events.guild.update.*; import net.dv8tion.jda.api.events.guild.voice.GuildVoiceUpdateEvent; import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent; import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent; import net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent; import net.dv8tion.jda.api.events.message.MessageDeleteEvent; import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.events.role.RoleCreateEvent; import net.dv8tion.jda.api.events.role.RoleDeleteEvent; import net.dv8tion.jda.api.events.role.update.*; import net.dv8tion.jda.api.events.sticker.GuildStickerAddedEvent; import net.dv8tion.jda.api.events.sticker.GuildStickerRemovedEvent; import net.dv8tion.jda.api.events.sticker.update.GuildStickerUpdateNameEvent; import net.dv8tion.jda.api.events.user.update.UserUpdateAvatarEvent; import net.dv8tion.jda.api.events.user.update.UserUpdateGlobalNameEvent; import net.dv8tion.jda.api.events.user.update.UserUpdateNameEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.DependsOn; import org.springframework.stereotype.Service; import java.util.HashSet; import java.util.Set; /** * @author Fascinated (fascinated7) */ @Service @Log4j2(topic = "Event Service") @DependsOn("discordService") public class EventService extends ListenerAdapter { /** * The list of listeners registered */ public static final Set LISTENERS = new HashSet<>(); private final GuildService guildService; private final UserService userService; private final DiscordMessageService discordMessageService; @Autowired public EventService(@NonNull ApplicationContext context, @NonNull GuildService guildService, @NonNull UserService userService, @NonNull DiscordMessageService discordMessageService) { this.guildService = guildService; this.userService = userService; this.discordMessageService = discordMessageService; DiscordService.JDA.addEventListener(this); context.getBeansOfType(EventListener.class).values().forEach(this::registerListeners); log.info("Registered {} event listeners.", LISTENERS.size()); } /** * Registers an event listener * * @param listener the listener to register */ public void registerListeners(EventListener... listener) { LISTENERS.addAll(Set.of(listener)); } @Override public void onGuildMemberJoin(@NotNull GuildMemberJoinEvent event) { if (event.getUser().isBot()) { return; } BatGuild guild = guildService.getGuild(event.getGuild().getId()); BatUser user = userService.getUser(event.getUser().getId(), event.getUser()); for (EventListener listener : LISTENERS) { listener.onGuildMemberJoin(guild, user, event); } } @Override public void onGuildMemberRemove(@NonNull GuildMemberRemoveEvent event) { if (event.getUser().isBot()) { return; } BatGuild guild = guildService.getGuild(event.getGuild().getId()); BatUser user = userService.getUser(event.getUser().getId(), event.getUser()); for (EventListener listener : LISTENERS) { listener.onGuildMemberLeave(guild, user, event); } } @Override public void onMessageReceived(MessageReceivedEvent event) { if (event.getAuthor().isBot()) { return; } BatGuild guild = guildService.getGuild(event.getGuild().getId()); BatUser user = userService.getUser(event.getAuthor().getId(), event.getAuthor()); for (EventListener listener : LISTENERS) { listener.onGuildMessageReceive(guild, user, event); } } @Override public void onMessageDelete(@NotNull MessageDeleteEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); DiscordMessage message = discordMessageService.getMessage(event.getMessageId()); BatUser user = message == null ? null : userService.getUser(message.getAuthorId()); for (EventListener listener : LISTENERS) { listener.onGuildMessageDelete(guild, user, message, event); } } @Override public void onStringSelectInteraction(StringSelectInteractionEvent event) { if (event.getUser().isBot()) { return; } BatGuild guild = event.getGuild() == null ? null : guildService.getGuild(event.getGuild().getId()); BatUser user = userService.getUser(event.getUser().getId(), event.getUser()); for (EventListener listener : LISTENERS) { listener.onStringSelectInteraction(guild, user, event); } } @Override public void onButtonInteraction(ButtonInteractionEvent event) { if (event.getUser().isBot()) { return; } BatGuild guild = event.getGuild() == null ? null : guildService.getGuild(event.getGuild().getId()); BatUser user = userService.getUser(event.getUser().getId(), event.getUser()); try { for (EventListener listener : LISTENERS) { listener.onButtonInteraction(guild, user, event); } } catch (Exception ex) { log.error("An error occurred while handling a modal interaction.", ex); event.replyEmbeds(EmbedUtils.genericInteractionError(ex).build()).setEphemeral(true).queue(); } } @Override public void onModalInteraction(ModalInteractionEvent event) { if (event.getUser().isBot()) { return; } BatGuild guild = event.getGuild() == null ? null : guildService.getGuild(event.getGuild().getId()); BatUser user = userService.getUser(event.getUser().getId(), event.getUser()); try { for (EventListener listener : LISTENERS) { listener.onModalInteraction(guild, user, event); } } catch (Exception ex) { log.error("An error occurred while handling a modal interaction.", ex); event.replyEmbeds(EmbedUtils.genericInteractionError(ex).build()).setEphemeral(true).queue(); } } @Override public void onUserUpdateGlobalName(@NotNull UserUpdateGlobalNameEvent event) { if (event.getUser().isBot()) { return; } BatUser user = userService.getUser(event.getUser().getId(), event.getUser()); for (EventListener listener : LISTENERS) { listener.onUserUpdateGlobalName(user, event.getOldGlobalName(), event.getNewGlobalName(), event); } } @Override public void onGuildMemberUpdateNickname(@NotNull GuildMemberUpdateNicknameEvent event) { if (event.getUser().isBot()) { return; } BatGuild guild = guildService.getGuild(event.getGuild().getId()); BatUser user = userService.getUser(event.getUser().getId(), event.getUser()); for (EventListener listener : LISTENERS) { listener.onGuildMemberUpdateNickname(guild, user, event.getOldNickname(), event.getNewNickname(), event); } } @Override public void onGuildMemberRoleAdd(@NotNull GuildMemberRoleAddEvent event) { if (event.getUser().isBot()) { return; } BatGuild guild = guildService.getGuild(event.getGuild().getId()); BatUser user = userService.getUser(event.getUser().getId(), event.getUser()); for (EventListener listener : LISTENERS) { listener.onGuildMemberRoleAdd(guild, user, event.getRoles(), event); } } @Override public void onGuildMemberRoleRemove(@NotNull GuildMemberRoleRemoveEvent event) { if (event.getUser().isBot()) { return; } BatGuild guild = guildService.getGuild(event.getGuild().getId()); BatUser user = userService.getUser(event.getUser().getId(), event.getUser()); for (EventListener listener : LISTENERS) { listener.onGuildMemberRoleRemove(guild, user, event.getRoles(), event); } } @Override public void onChannelCreate(@NotNull ChannelCreateEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onChannelCreate(guild, event); } } @Override public void onChannelDelete(@NotNull ChannelDeleteEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onChannelDelete(guild, event); } } @Override public void onGuildBan(@NotNull GuildBanEvent event) { if (event.getUser().isBot()) { return; } BatGuild guild = guildService.getGuild(event.getGuild().getId()); BatUser user = userService.getUser(event.getUser().getId(), event.getUser()); for (EventListener listener : LISTENERS) { listener.onGuildMemberBan(guild, user, event); } } @Override public void onGuildUnban(@NotNull GuildUnbanEvent event) { if (event.getUser().isBot()) { return; } BatGuild guild = guildService.getGuild(event.getGuild().getId()); BatUser user = userService.getUser(event.getUser().getId(), event.getUser()); for (EventListener listener : LISTENERS) { listener.onGuildMemberUnban(guild, user, event); } } @Override public void onGuildMemberUpdateTimeOut(@NotNull GuildMemberUpdateTimeOutEvent event) { if (event.getUser().isBot()) { return; } BatGuild guild = guildService.getGuild(event.getGuild().getId()); BatUser user = userService.getUser(event.getUser().getId(), event.getUser()); for (EventListener listener : LISTENERS) { listener.onGuildMemberTimeout(guild, user, event); } } @Override public void onUserUpdateName(@NotNull UserUpdateNameEvent event) { if (event.getUser().isBot()) { return; } BatUser user = userService.getUser(event.getUser().getId(), event.getUser()); for (EventListener listener : LISTENERS) { listener.onUserUpdateName(user, event.getOldName(), event.getNewName(), event); } } @Override public void onUserUpdateAvatar(@NotNull UserUpdateAvatarEvent event) { if (event.getUser().isBot()) { return; } BatUser user = userService.getUser(event.getUser().getId(), event.getUser()); for (EventListener listener : LISTENERS) { listener.onUserUpdateAvatar(user, event.getOldAvatarUrl(), event.getNewAvatarUrl(), event); } } @Override public void onGuildVoiceUpdate(@NotNull GuildVoiceUpdateEvent event) { if (event.getEntity().getUser().isBot()) { return; } BatGuild guild = guildService.getGuild(event.getEntity().getGuild().getId()); BatUser user = userService.getUser(event.getEntity().getUser().getId(), event.getEntity().getUser()); for (EventListener listener : LISTENERS) { listener.onGuildVoiceUpdate(guild, user, event); } } @Override public void onGuildInviteCreate(@NotNull GuildInviteCreateEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); Invite invite = event.getInvite(); for (EventListener listener : LISTENERS) { listener.onGuildInviteCreate(guild, invite, event); } } @Override public void onGuildMemberUpdateBoostTime(@NotNull GuildMemberUpdateBoostTimeEvent event) { if (event.getUser().isBot()) { return; } BatGuild guild = guildService.getGuild(event.getGuild().getId()); BatUser user = userService.getUser(event.getUser().getId(), event.getUser()); // Boost tier(s) added if (event.getNewTimeBoosted() != null) { for (EventListener listener : LISTENERS) { listener.onGuildMemberBoostAdd(guild, user, event.getOldTimeBoosted(), event.getNewTimeBoosted(), event); } } // Boost tier(s) removed if (event.getOldTimeBoosted() != null) { for (EventListener listener : LISTENERS) { listener.onGuildMemberBoostRemove(guild, user, event.getOldTimeBoosted(), event.getNewTimeBoosted(), event); } } } @Override public void onEmojiAdded(@NotNull EmojiAddedEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onEmojiAdd(guild, event.getEmoji(), event); } } @Override public void onEmojiRemoved(@NotNull EmojiRemovedEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onEmojiRemove(guild, event.getEmoji(), event); } } @Override public void onEmojiUpdateName(@NotNull EmojiUpdateNameEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onEmojiRename(guild, event.getEmoji(), event.getOldName(), event.getNewName(), event); } } @Override public void onChannelUpdateName(@NotNull ChannelUpdateNameEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onChannelUpdateName(guild, event); } } @Override public void onGenericPermissionOverride(@NotNull GenericPermissionOverrideEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onPermissionOverride(guild, event); } } @Override public void onRoleUpdatePermissions(@NotNull RoleUpdatePermissionsEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onRoleUpdatePermissions(guild, event); } } @Override public void onRoleCreate(@NotNull RoleCreateEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onRoleCreate(guild, event); } } @Override public void onRoleDelete(@NotNull RoleDeleteEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onRoleDelete(guild, event); } } @Override public void onRoleUpdateName(@NotNull RoleUpdateNameEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onRoleUpdateName(guild, event); } } @Override public void onRoleUpdateColor(@NotNull RoleUpdateColorEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onRoleUpdateColor(guild, event); } } @Override public void onRoleUpdateIcon(@NotNull RoleUpdateIconEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onRoleUpdateIcon(guild, event); } } @Override public void onChannelUpdateTopic(@NotNull ChannelUpdateTopicEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onChannelUpdateTopic(guild, event); } } @Override public void onChannelUpdateBitrate(@NotNull ChannelUpdateBitrateEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onChannelUpdateBitrate(guild, event); } } @Override public void onChannelUpdateNSFW(@NotNull ChannelUpdateNSFWEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onChannelUpdateNSFW(guild, event); } } @Override public void onChannelUpdateUserLimit(@NotNull ChannelUpdateUserLimitEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onChannelUpdateUserLimit(guild, event); } } @Override public void onChannelUpdateRegion(@NotNull ChannelUpdateRegionEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onChannelUpdateRegion(guild, event); } } @Override public void onChannelUpdateSlowmode(@NotNull ChannelUpdateSlowmodeEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onChannelUpdateSlowmode(guild, event); } } @Override public void onGuildUpdateName(@NotNull GuildUpdateNameEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onGuildUpdateName(guild, event.getOldName(), event.getNewName(), event); } } @Override public void onGuildStickerAdded(@NotNull GuildStickerAddedEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onGuildStickerAdd(guild, event.getSticker(), event); } } @Override public void onGuildStickerRemoved(@NotNull GuildStickerRemovedEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onGuildStickerRemove(guild, event.getSticker(), event); } } @Override public void onGuildStickerUpdateName(@NotNull GuildStickerUpdateNameEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onGuildStickerRename(guild, event.getSticker(), event.getOldValue(), event.getNewValue(), event); } } @Override public void onGuildUpdateAfkChannel(@NotNull GuildUpdateAfkChannelEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onGuildUpdateAfkChannel(guild, event.getOldAfkChannel(), event.getNewAfkChannel(), event); } } @Override public void onGuildUpdateAfkTimeout(@NotNull GuildUpdateAfkTimeoutEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onGuildUpdateAfkTimeout(guild, event.getOldAfkTimeout(), event.getNewAfkTimeout(), event); } } @Override public void onGuildUpdateBanner(@NotNull GuildUpdateBannerEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onGuildUpdateBanner(guild, event.getOldBannerUrl(), event.getNewBannerUrl(), event); } } @Override public void onGuildUpdateDescription(@NotNull GuildUpdateDescriptionEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onGuildUpdateDescription(guild, event.getOldDescription(), event.getNewDescription(), event); } } @Override public void onGuildUpdateIcon(@NotNull GuildUpdateIconEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onGuildUpdateIcon(guild, event.getOldIconUrl(), event.getNewIconUrl(), event); } } @Override public void onGuildUpdateLocale(@NotNull GuildUpdateLocaleEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onGuildUpdateLocale(guild, event.getOldValue(), event.getNewValue(), event); } } @Override public void onGuildUpdateCommunityUpdatesChannel(@NotNull GuildUpdateCommunityUpdatesChannelEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onGuildUpdateCommunityUpdatesChannel(guild, event.getOldCommunityUpdatesChannel(), event.getNewCommunityUpdatesChannel(), event); } } @Override public void onGuildUpdateBoostTier(@NotNull GuildUpdateBoostTierEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onGuildUpdateBoostTier(guild, event.getOldBoostTier(), event.getNewBoostTier(), event); } } @Override public void onGuildUpdateMaxMembers(@NotNull GuildUpdateMaxMembersEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onGuildUpdateMaxMembers(guild, event.getOldMaxMembers(), event.getNewMaxMembers(), event); } } @Override public void onGuildUpdateExplicitContentLevel(@NotNull GuildUpdateExplicitContentLevelEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onGuildUpdateExplicitContentLevel(guild, event.getOldLevel(), event.getNewLevel(), event); } } @Override public void onGuildUpdateMFALevel(@NotNull GuildUpdateMFALevelEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onGuildUpdateMFALevel(guild, event.getOldMFALevel(), event.getNewMFALevel(), event); } } @Override public void onGuildUpdateNotificationLevel(@NotNull GuildUpdateNotificationLevelEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onGuildUpdateNotificationLevel(guild, event.getOldNotificationLevel(), event.getNewNotificationLevel(), event); } } @Override public void onGuildUpdateNSFWLevel(@NotNull GuildUpdateNSFWLevelEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onGuildUpdateNSFWLevel(guild, event.getOldNSFWLevel(), event.getNewNSFWLevel(), event); } } @Override public void onGuildUpdateOwner(@NotNull GuildUpdateOwnerEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); if (event.getOldOwner() == null || event.getNewOwner() == null) { return; } BatUser oldOwner = userService.getUser(event.getOldOwner().getId(), event.getOldOwner().getUser()); BatUser newOwner = userService.getUser(event.getNewOwner().getId(), event.getNewOwner().getUser()); for (EventListener listener : LISTENERS) { listener.onGuildUpdateOwner(guild, oldOwner, newOwner, event); } } @Override public void onGuildUpdateRulesChannel(@NotNull GuildUpdateRulesChannelEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onGuildUpdateRulesChannel(guild, event.getOldRulesChannel(), event.getNewRulesChannel(), event); } } @Override public void onGuildUpdateSystemChannel(@NotNull GuildUpdateSystemChannelEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onGuildUpdateSystemChannel(guild, event.getOldSystemChannel(), event.getNewSystemChannel(), event); } } @Override public void onGuildUpdateVanityCode(@NotNull GuildUpdateVanityCodeEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onGuildUpdateVanityCode(guild, event.getOldVanityCode(), event.getNewVanityCode(), event); } } @Override public void onGuildUpdateVerificationLevel(@NotNull GuildUpdateVerificationLevelEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onGuildUpdateVerificationLevel(guild, event.getOldVerificationLevel(), event.getNewVerificationLevel(), event); } } @Override public void onGuildUpdateSplash(@NotNull GuildUpdateSplashEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onGuildUpdateSplash(guild, event.getOldSplashUrl(), event.getNewSplashUrl(), event); } } @Override public void onChannelUpdateArchived(@NotNull ChannelUpdateArchivedEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onChannelUpdateArchived(guild, event.getEntity(), Boolean.TRUE.equals(event.getNewValue()), event); } } @Override public void onRoleUpdatePosition(@NotNull RoleUpdatePositionEvent event) { BatGuild guild = guildService.getGuild(event.getGuild().getId()); for (EventListener listener : LISTENERS) { listener.onRoleUpdatePosition(guild, event.getRole(), event.getOldPosition(), event.getNewPosition(), event); } } }