From 3e140cd4c26931ca2e305390465b7ddd2ab03e7f Mon Sep 17 00:00:00 2001 From: Michael Ritter Date: Sun, 21 Oct 2018 17:31:02 +0200 Subject: [PATCH] Lay out initial code for announcement mute role This commit modifies MiscUtils.announce() to also revoke write permission from a special announce mute role. It also moves a lot of static hardcoded IDs for entities + some entity getters to a common EntityLookup class (name subject to change). TODO: Create Role and fill in ID in EntityLookup --- .../almightyalpaca/discord/jdabutler/Bot.java | 31 +-- .../discord/jdabutler/EntityLookup.java | 59 +++++ .../discord/jdabutler/EventListener.java | 6 +- .../jdabutler/commands/Dispatcher.java | 7 +- .../commands/AnnouncementCommand.java | 3 +- .../commands/commands/NotifyCommand.java | 204 +----------------- .../discord/jdabutler/util/MiscUtils.java | 22 +- .../fakebutler/FakeButlerListener.java | 18 +- .../versioncheck/items/VersionedItem.java | 6 +- 9 files changed, 103 insertions(+), 253 deletions(-) create mode 100644 src/main/java/com/almightyalpaca/discord/jdabutler/EntityLookup.java diff --git a/src/main/java/com/almightyalpaca/discord/jdabutler/Bot.java b/src/main/java/com/almightyalpaca/discord/jdabutler/Bot.java index 5345f66b..88b3dd46 100644 --- a/src/main/java/com/almightyalpaca/discord/jdabutler/Bot.java +++ b/src/main/java/com/almightyalpaca/discord/jdabutler/Bot.java @@ -5,7 +5,6 @@ import ch.qos.logback.classic.encoder.PatternLayoutEncoder; import ch.qos.logback.classic.filter.ThresholdFilter; import com.almightyalpaca.discord.jdabutler.commands.Dispatcher; -import com.almightyalpaca.discord.jdabutler.commands.commands.NotifyCommand; import com.almightyalpaca.discord.jdabutler.config.Config; import com.almightyalpaca.discord.jdabutler.config.ConfigFactory; import com.almightyalpaca.discord.jdabutler.config.exception.KeyNotFoundException; @@ -50,38 +49,18 @@ public class Bot public static final ScheduledExecutorService EXECUTOR = Executors.newSingleThreadScheduledExecutor(MiscUtils.newThreadFactory("main-executor")); - public static Guild getGuildJda() - { - return Bot.jda.getGuildById("125227483518861312"); - } - - public static Role getRoleBots() - { - return Bot.getGuildJda().getRoleById("125616720156033024"); - } - - public static Role getRoleStaff() - { - return Bot.getGuildJda().getRoleById("169481978268090369"); - } - public static boolean isAdmin(final User user) { - final Member member = Bot.getGuildJda().getMember(user); - return member != null && member.getRoles().contains(Bot.getRoleStaff()); - } - - public static Role getRoleHelper() - { - return Bot.getGuildJda().getRoleById("183963327033114624"); + final Member member = EntityLookup.getGuildJda().getMember(user); + return member != null && member.getRoles().contains(EntityLookup.getRoleStaff()); } public static boolean isHelper(final User user) { if(isAdmin(user)) return true; - final Member member = Bot.getGuildJda().getMember(user); - return member != null && member.getRoles().contains(Bot.getRoleHelper()); + final Member member = EntityLookup.getGuildJda().getMember(user); + return member != null && member.getRoles().contains(EntityLookup.getRoleHelper()); } public static void main(final String[] args) throws JsonIOException, JsonSyntaxException, WrongTypeException, KeyNotFoundException, IOException, LoginException, IllegalArgumentException, InterruptedException, SecurityException @@ -136,8 +115,6 @@ public static void main(final String[] args) throws JsonIOException, JsonSyntaxE root.addAppender(appender); } - NotifyCommand.reloadBlacklist(null); - EXECUTOR.submit(() -> { VersionCheckerRegistry.init(); diff --git a/src/main/java/com/almightyalpaca/discord/jdabutler/EntityLookup.java b/src/main/java/com/almightyalpaca/discord/jdabutler/EntityLookup.java new file mode 100644 index 00000000..9563cf0c --- /dev/null +++ b/src/main/java/com/almightyalpaca/discord/jdabutler/EntityLookup.java @@ -0,0 +1,59 @@ +package com.almightyalpaca.discord.jdabutler; + +import net.dv8tion.jda.core.entities.Guild; +import net.dv8tion.jda.core.entities.Role; + +public class EntityLookup +{ + + /* + JDA Guild + */ + public static final long GUILD_JDA_ID = 125227483518861312L; + public static Guild getGuildJda() + { + return Bot.jda.getGuildById(GUILD_JDA_ID); + } + + //ROLES + public static final long ROLE_BOTS_ID = 125616720156033024L; + public static Role getRoleBots() + { + return getGuildJda().getRoleById(ROLE_BOTS_ID); + } + + public static final long ROLE_STAFF_ID = 169481978268090369L; + public static Role getRoleStaff() + { + return getGuildJda().getRoleById(ROLE_STAFF_ID); + } + + public static final long ROLE_HELPERS_ID = 183963327033114624L; + public static Role getRoleHelper() + { + return getGuildJda().getRoleById(ROLE_HELPERS_ID); + } + + //todo + public static final long ROLE_ANNOUNCEMUTE_ID = -1L; + public static Role getRoleAnnounceMute() + { + return getGuildJda().getRoleById(ROLE_ANNOUNCEMUTE_ID); + } + + + /* + DAPI Guild + */ + public static final long GUILD_DAPI_ID = 81384788765712384L; + + //CHANNELS/CATEGORIES + public static final long CHANNEL_DAPI_JDA_ID = 381889648827301889L; + public static final long CATEGORY_DAPI_TESTING_ID = 356505966201798656L; + + + /* + USERS + */ + public static final long MAIN_BUTLER_ID = 189074312974696448L; +} diff --git a/src/main/java/com/almightyalpaca/discord/jdabutler/EventListener.java b/src/main/java/com/almightyalpaca/discord/jdabutler/EventListener.java index b4ae8b39..c28b313f 100644 --- a/src/main/java/com/almightyalpaca/discord/jdabutler/EventListener.java +++ b/src/main/java/com/almightyalpaca/discord/jdabutler/EventListener.java @@ -21,11 +21,11 @@ public void onGuildMemberJoin(final GuildMemberJoinEvent event) if(user.isBot()) { final AuditableRestAction action = guild.getController() - .addSingleRoleToMember(member, Bot.getRoleBots()).reason("Auto Role"); - final String message = String.format("Added %#s (%d) to %s", user, user.getIdLong(), Bot.getRoleBots().getName()); + .addSingleRoleToMember(member, EntityLookup.getRoleBots()).reason("Auto Role"); + final String message = String.format("Added %#s (%d) to %s", user, user.getIdLong(), EntityLookup.getRoleBots().getName()); action.queue( v -> Bot.LOG.info(message), - ex -> Bot.LOG.error("Could not add User {} to role {}", user.getName(), Bot.getRoleBots().getName(), ex) + ex -> Bot.LOG.error("Could not add User {} to role {}", user.getName(), EntityLookup.getRoleBots().getName(), ex) ); } } diff --git a/src/main/java/com/almightyalpaca/discord/jdabutler/commands/Dispatcher.java b/src/main/java/com/almightyalpaca/discord/jdabutler/commands/Dispatcher.java index ee7d74f1..deaef2ce 100644 --- a/src/main/java/com/almightyalpaca/discord/jdabutler/commands/Dispatcher.java +++ b/src/main/java/com/almightyalpaca/discord/jdabutler/commands/Dispatcher.java @@ -1,6 +1,7 @@ package com.almightyalpaca.discord.jdabutler.commands; import com.almightyalpaca.discord.jdabutler.Bot; +import com.almightyalpaca.discord.jdabutler.EntityLookup; import com.almightyalpaca.discord.jdabutler.commands.commands.*; import com.almightyalpaca.discord.jdabutler.commands.commands.moderation.SoftbanCommand; import com.almightyalpaca.discord.jdabutler.util.MiscUtils; @@ -78,9 +79,9 @@ public void onGuildMessageReceived(final GuildMessageReceivedEvent event) final TextChannel channel = event.getChannel(); - if (channel.getGuild().getIdLong() == 81384788765712384L // if DAPI - && !(channel.getIdLong() == 381889648827301889L // and not #java_jda - || (channel.getParent() != null && channel.getParent().getIdLong() == 356505966201798656L))) // or not testing category + if (channel.getGuild().getIdLong() == EntityLookup.GUILD_DAPI_ID // if DAPI + && !(channel.getIdLong() == EntityLookup.CHANNEL_DAPI_JDA_ID // and not #java_jda + || (channel.getParent() != null && channel.getParent().getIdLong() == EntityLookup.CATEGORY_DAPI_TESTING_ID))) // and not testing category return; // ignore message if (message.toLowerCase().startsWith(prefix.toLowerCase())) diff --git a/src/main/java/com/almightyalpaca/discord/jdabutler/commands/commands/AnnouncementCommand.java b/src/main/java/com/almightyalpaca/discord/jdabutler/commands/commands/AnnouncementCommand.java index 1e6eef6b..ba5c5d6c 100644 --- a/src/main/java/com/almightyalpaca/discord/jdabutler/commands/commands/AnnouncementCommand.java +++ b/src/main/java/com/almightyalpaca/discord/jdabutler/commands/commands/AnnouncementCommand.java @@ -1,6 +1,7 @@ package com.almightyalpaca.discord.jdabutler.commands.commands; import com.almightyalpaca.discord.jdabutler.Bot; +import com.almightyalpaca.discord.jdabutler.EntityLookup; import com.almightyalpaca.discord.jdabutler.util.EmbedUtil; import com.almightyalpaca.discord.jdabutler.commands.Command; import com.almightyalpaca.discord.jdabutler.util.MiscUtils; @@ -26,7 +27,7 @@ public class AnnouncementCommand extends Command @Override public void dispatch(final User sender, final TextChannel channel, final Message message, final String content, final GuildMessageReceivedEvent event) { - if(!channel.getGuild().equals(Bot.getGuildJda())) + if(!channel.getGuild().equals(EntityLookup.getGuildJda())) { this.sendFailed(message); return; diff --git a/src/main/java/com/almightyalpaca/discord/jdabutler/commands/commands/NotifyCommand.java b/src/main/java/com/almightyalpaca/discord/jdabutler/commands/commands/NotifyCommand.java index b31a0be9..31e43126 100644 --- a/src/main/java/com/almightyalpaca/discord/jdabutler/commands/commands/NotifyCommand.java +++ b/src/main/java/com/almightyalpaca/discord/jdabutler/commands/commands/NotifyCommand.java @@ -1,20 +1,14 @@ package com.almightyalpaca.discord.jdabutler.commands.commands; import com.almightyalpaca.discord.jdabutler.Bot; +import com.almightyalpaca.discord.jdabutler.EntityLookup; import com.almightyalpaca.discord.jdabutler.commands.Command; import com.kantenkugel.discordbot.versioncheck.VersionCheckerRegistry; import com.kantenkugel.discordbot.versioncheck.items.VersionedItem; -import gnu.trove.set.TLongSet; -import gnu.trove.set.hash.TLongHashSet; -import net.dv8tion.jda.core.audit.ActionType; -import net.dv8tion.jda.core.audit.AuditLogChange; -import net.dv8tion.jda.core.audit.AuditLogKey; import net.dv8tion.jda.core.entities.*; import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; -import java.time.OffsetDateTime; import java.util.List; -import java.util.Map; import java.util.Objects; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -22,43 +16,20 @@ public class NotifyCommand extends Command { - private static final long BLACKLIST_CHANNEL_ID = 454657809397710859L; private static final String[] ALIASES = { "subscribe" }; - private static final TLongSet BLACKLIST = new TLongHashSet(); - @Override public void dispatch(final User sender, final TextChannel channel, final Message message, final String content, final GuildMessageReceivedEvent event) { final Member member = channel.getGuild().getMember(sender); final Guild guild = channel.getGuild(); - if (!guild.equals(Bot.getGuildJda())) + if (!guild.equals(EntityLookup.getGuildJda())) { this.sendFailed(message); return; } - if(content.startsWith("blacklist")) - { - if(Bot.isAdmin(sender)) - { - String subContent = content.substring(Math.min("blacklist".length() + 1, content.length())); - handleBlacklist(event, message, subContent); - } - else - { - sendFailed(message); - } - return; - } - - if(BLACKLIST.contains(sender.getIdLong())) - { - message.addReaction("\uD83D\uDE49").queue(); - return; - } - final List roles; if(content.trim().isEmpty()) { @@ -148,177 +119,6 @@ public String getName() return "notify"; } - public static void reloadBlacklist(GuildMessageReceivedEvent event) - { - TextChannel blacklistChannel = getBlacklistChannel(); - BLACKLIST.clear(); - blacklistChannel.getIterableHistory().forEachAsync(message -> - { - String[] split = message.getContentRaw().split("\\s+"); - try - { - long userId = Long.parseUnsignedLong(split[0]); - BLACKLIST.add(userId); - } - catch(NumberFormatException ex) - { - if(event != null) - event.getChannel().sendMessageFormat("Message `%s` is not a valid blacklist message", message.getContentStripped()) - .queue(msg -> linkMessage(event.getMessageIdLong(), msg.getIdLong())); - } - return true; - }).thenRun(() -> - { - if(event != null) - event.getChannel().sendMessage("Reloaded " + BLACKLIST.size() + " users into blacklist").queue(msg -> - linkMessage(event.getMessageIdLong(), msg.getIdLong())); - }); - } - - private void handleBlacklist(GuildMessageReceivedEvent event, Message msg, String content) - { - if(content.isEmpty()) - { - sendFailed(msg); - return; - } - String[] args = content.split("\\s+", 2); - TextChannel blacklistChannel = getBlacklistChannel(); - switch(args[0].toLowerCase()) - { - case "fetch": - case "generate": - case "get": - TextChannel searchChannel = msg.getMentionedChannels().isEmpty() - ? VersionCheckerRegistry.getItem("jda").getAnnouncementChannel() - : msg.getMentionedChannels().get(0); - if(searchChannel == null) - reply(event, "Could not determine channel to search in"); - else - fetchBlacklist(searchChannel, event); - break; - case "update": - case "import": - case "reload": - reloadBlacklist(event); - break; - case "add": - msg.getMentionedUsers().forEach(u -> - { - if(!BLACKLIST.contains(u.getIdLong())) - { - BLACKLIST.add(u.getIdLong()); - sendBlacklistAdditionMessage(blacklistChannel, u); - } - }); - msg.addReaction("\u2705").queue(); - break; - case "rm": - case "remove": - TLongSet removedIds = new TLongHashSet(); - msg.getMentionedUsers().forEach(u -> - { - if(BLACKLIST.contains(u.getIdLong())) - { - BLACKLIST.remove(u.getIdLong()); - removedIds.add(u.getIdLong()); - } - }); - removeFromChannel(blacklistChannel, removedIds); - msg.addReaction("\u2705").queue(); - break; - default: - reply(event, "Unknown subcommand"); - } - } - - private void fetchBlacklist(TextChannel searchChannel, GuildMessageReceivedEvent event) - { - Message mentionMessage = searchChannel.getIterableHistory().stream() - .filter(message -> message.getAuthor().isBot() && !message.getMentionedRoles().isEmpty()) - .limit(500).findFirst().orElse(null); - if(mentionMessage == null) - { - reply(event, "Could not find announcement message within 500 messages"); - return; - } - - Role announcementRole = mentionMessage.getMentionedRoles().get(0); - OffsetDateTime abortTime = mentionMessage.getCreationTime(); - - TLongSet blacklistedUsers = new TLongHashSet(); - - searchChannel.getGuild().getAuditLogs().type(ActionType.MEMBER_ROLE_UPDATE).forEachAsync(log -> - { - if(log.getCreationTime().isBefore(abortTime)) - return false; - AuditLogChange removedRoles = log.getChangeByKey(AuditLogKey.MEMBER_ROLES_REMOVE); - if(removedRoles == null) - return true; - - if(log.getUser() == null || log.getUser().isBot() || !Bot.isAdmin(log.getUser())) - return true; - - - List> removedRoleMap = removedRoles.getNewValue(); - if(removedRoleMap.stream().mapToLong(map -> Long.parseUnsignedLong(map.get("id"))).noneMatch(rem -> rem == announcementRole.getIdLong())) - return true; - - blacklistedUsers.add(log.getTargetIdLong()); - - return true; - }).thenRun(() -> - { - if(blacklistedUsers.isEmpty() || (blacklistedUsers.removeAll(BLACKLIST) && blacklistedUsers.isEmpty())) - { - reply(event, "No1 matching blacklist criteria found!"); - return; - } - BLACKLIST.addAll(blacklistedUsers); - TextChannel blacklistChannel = getBlacklistChannel(); - blacklistedUsers.forEach(userId -> - { - sendBlacklistAdditionMessage(blacklistChannel, Bot.jda.getUserById(userId)); - return true; - }); - reply(event, "Added " + blacklistedUsers.size() + " users to notify blacklist"); - }); - } - - private static void sendBlacklistAdditionMessage(TextChannel blacklistChannel, User blacklisted) - { - blacklistChannel.sendMessageFormat("%d - %#s", blacklisted.getIdLong(), blacklisted).queue(); - } - - private static void removeFromChannel(TextChannel blacklistChannel, TLongSet toRemove) - { - if(toRemove.isEmpty()) - return; - blacklistChannel.getIterableHistory().forEachAsync(msg -> - { - String[] splits = msg.getContentRaw().split("\\s+"); - try - { - long idFromMessage = Long.parseUnsignedLong(splits[0]); - if(toRemove.contains(idFromMessage)) - { - toRemove.remove(idFromMessage); - msg.delete().queue(); - if(toRemove.isEmpty()) - return false; - } - } - catch(NumberFormatException ignored) {} - - return true; - }); - } - - private static TextChannel getBlacklistChannel() - { - return Bot.jda.getTextChannelById(BLACKLIST_CHANNEL_ID); - } - private static void respond(Message origMsg, String newMessageContent) { origMsg.getChannel().sendMessage(newMessageContent).queue(responseMsg -> diff --git a/src/main/java/com/almightyalpaca/discord/jdabutler/util/MiscUtils.java b/src/main/java/com/almightyalpaca/discord/jdabutler/util/MiscUtils.java index d02a1b98..6a3e6470 100644 --- a/src/main/java/com/almightyalpaca/discord/jdabutler/util/MiscUtils.java +++ b/src/main/java/com/almightyalpaca/discord/jdabutler/util/MiscUtils.java @@ -1,9 +1,13 @@ package com.almightyalpaca.discord.jdabutler.util; import com.almightyalpaca.discord.jdabutler.Bot; +import com.almightyalpaca.discord.jdabutler.EntityLookup; +import net.dv8tion.jda.core.Permission; import net.dv8tion.jda.core.entities.Message; +import net.dv8tion.jda.core.entities.PermissionOverride; import net.dv8tion.jda.core.entities.Role; import net.dv8tion.jda.core.entities.TextChannel; +import net.dv8tion.jda.core.requests.RequestFuture; import okhttp3.*; import org.json.JSONObject; import org.json.JSONTokener; @@ -76,13 +80,23 @@ public static String hastebin(final String text) } } - public static void announce(TextChannel channel, Role role, Message message, boolean slowmode) + private static final long ANTI_SPAM_MINUTES = 2; + public static void announce(TextChannel channel, Role role, Message message, boolean preventSpam) { CompletionStage base; - if (slowmode) + if (preventSpam) { - base = channel.getManager().setSlowmode(30).submit(); - base.thenRun(() -> channel.getManager().setSlowmode(0).queueAfter(2, TimeUnit.MINUTES)); + base = RequestFuture.allOf( + channel.getManager().setSlowmode(30).submit(), + channel.putPermissionOverride(EntityLookup.getRoleAnnounceMute()).setDeny(Permission.MESSAGE_WRITE).submit() + ); + base.thenRun(() -> + { + channel.getManager().setSlowmode(0).queueAfter(ANTI_SPAM_MINUTES, TimeUnit.MINUTES); + PermissionOverride override = channel.getPermissionOverride(EntityLookup.getRoleAnnounceMute()); + if(override != null) + override.delete().queueAfter(ANTI_SPAM_MINUTES, TimeUnit.MINUTES, null, (ex) -> {}); + }); } else { diff --git a/src/main/java/com/kantenkugel/discordbot/fakebutler/FakeButlerListener.java b/src/main/java/com/kantenkugel/discordbot/fakebutler/FakeButlerListener.java index 7b421171..d3d1067d 100644 --- a/src/main/java/com/kantenkugel/discordbot/fakebutler/FakeButlerListener.java +++ b/src/main/java/com/kantenkugel/discordbot/fakebutler/FakeButlerListener.java @@ -1,7 +1,7 @@ package com.kantenkugel.discordbot.fakebutler; import com.almightyalpaca.discord.jdabutler.Bot; -import com.almightyalpaca.discord.jdabutler.commands.commands.NotifyCommand; +import com.almightyalpaca.discord.jdabutler.EntityLookup; import com.almightyalpaca.discord.jdabutler.commands.commands.StatsCommand; import com.almightyalpaca.discord.jdabutler.util.DurationUtils; import net.dv8tion.jda.core.JDA; @@ -15,11 +15,10 @@ import net.dv8tion.jda.core.hooks.EventListener; import net.dv8tion.jda.core.managers.Presence; +import static com.almightyalpaca.discord.jdabutler.EntityLookup.MAIN_BUTLER_ID; + public class FakeButlerListener implements EventListener { - private static final long REAL_BUTLER_ID = 189074312974696448L; - private static final long JDA_SERVER_ID = 125227483518861312L; - private long onlineTime; private long offlineTime; private long latestStamp; @@ -35,7 +34,7 @@ public String getStats(JDA jda) long sum = on + off; return String.format("%s stats since start of %s:\nOnline: %s (%.1f%%)\nOffline: %s (%.1f%%)", - jda.getUserById(REAL_BUTLER_ID), jda.getSelfUser(), + jda.getUserById(MAIN_BUTLER_ID), jda.getSelfUser(), DurationUtils.formatDuration(on), on*100f/sum, DurationUtils.formatDuration(off), off*100f/sum); } @@ -48,12 +47,12 @@ public void onEvent(Event event) UserUpdateOnlineStatusEvent e = (UserUpdateOnlineStatusEvent) event; Guild guild = e.getGuild(); User user = e.getUser(); - if(user.getIdLong() == REAL_BUTLER_ID && guild.getIdLong() == JDA_SERVER_ID) + if(user.getIdLong() == MAIN_BUTLER_ID && guild.getIdLong() == EntityLookup.GUILD_JDA_ID) handleStatus(e.getJDA(), guild.getMember(user)); } else if (event instanceof ReadyEvent) { - if(event.getJDA().getSelfUser().getIdLong() == REAL_BUTLER_ID) + if(event.getJDA().getSelfUser().getIdLong() == MAIN_BUTLER_ID) { event.getJDA().removeEventListener(this); return; @@ -61,13 +60,13 @@ else if (event instanceof ReadyEvent) Bot.dispatcher.registerCommand(new StatsCommand(this)); - Guild jdaGuild = event.getJDA().getGuildById(JDA_SERVER_ID); + Guild jdaGuild = EntityLookup.getGuildJda(); if (jdaGuild == null) { handleStatus(event.getJDA(), null); return; } - Member butler = jdaGuild.getMemberById(REAL_BUTLER_ID); + Member butler = jdaGuild.getMemberById(MAIN_BUTLER_ID); handleStatus(event.getJDA(), butler); latestStamp = System.currentTimeMillis(); onlineTime = offlineTime = 0L; @@ -82,7 +81,6 @@ private void handleStatus(JDA jda, Member butler) //Main Butler is offline if(presence.getStatus() == OnlineStatus.ONLINE) return; - NotifyCommand.reloadBlacklist(null); online = false; onlineTime += (System.currentTimeMillis() - latestStamp); presence.setStatus(OnlineStatus.ONLINE); diff --git a/src/main/java/com/kantenkugel/discordbot/versioncheck/items/VersionedItem.java b/src/main/java/com/kantenkugel/discordbot/versioncheck/items/VersionedItem.java index d70f8db6..2de5b445 100644 --- a/src/main/java/com/kantenkugel/discordbot/versioncheck/items/VersionedItem.java +++ b/src/main/java/com/kantenkugel/discordbot/versioncheck/items/VersionedItem.java @@ -1,6 +1,6 @@ package com.kantenkugel.discordbot.versioncheck.items; -import com.almightyalpaca.discord.jdabutler.Bot; +import com.almightyalpaca.discord.jdabutler.EntityLookup; import com.kantenkugel.discordbot.versioncheck.UpdateHandler; import com.kantenkugel.discordbot.versioncheck.VersionUtils; import com.kantenkugel.discordbot.versioncheck.changelog.ChangelogProvider; @@ -206,13 +206,13 @@ public final void setVersion(String version) public final Role getAnnouncementRole() { long rid = getAnnouncementRoleId(); - return rid == 0 ? null : Bot.getGuildJda().getRoleById(rid); + return rid == 0 ? null : EntityLookup.getGuildJda().getRoleById(rid); } public final TextChannel getAnnouncementChannel() { long cid = getAnnouncementChannelId(); - return cid == 0 ? null : Bot.getGuildJda().getTextChannelById(cid); + return cid == 0 ? null : EntityLookup.getGuildJda().getTextChannelById(cid); } @Override