From 040c644ab1e9b0e29aad0f5741ccf19187038351 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 4 Jul 2024 03:52:33 +0100 Subject: [PATCH] use the util for getting channels --- .../java/cc/fascinated/bat/common/TextChannelUtils.java | 2 +- .../bat/features/birthday/profile/BirthdayProfile.java | 3 ++- .../java/cc/fascinated/bat/features/logging/LogProfile.java | 2 +- .../bat/features/logging/command/ListSubCommand.java | 2 +- .../java/cc/fascinated/bat/features/reminder/Reminder.java | 3 ++- .../scoresaber/profile/guild/UserScoreFeedProfile.java | 3 ++- .../fascinated/bat/features/welcomer/WelcomerProfile.java | 3 ++- src/main/java/cc/fascinated/bat/model/DiscordMessage.java | 6 ++++-- 8 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/main/java/cc/fascinated/bat/common/TextChannelUtils.java b/src/main/java/cc/fascinated/bat/common/TextChannelUtils.java index 1efcd82..e7f1d0a 100644 --- a/src/main/java/cc/fascinated/bat/common/TextChannelUtils.java +++ b/src/main/java/cc/fascinated/bat/common/TextChannelUtils.java @@ -18,7 +18,7 @@ public class TextChannelUtils { if (id == null) { return false; } - return DiscordService.JDA.getTextChannelById(id) != null; + return ChannelUtils.getTextChannel(id) != null; } /** diff --git a/src/main/java/cc/fascinated/bat/features/birthday/profile/BirthdayProfile.java b/src/main/java/cc/fascinated/bat/features/birthday/profile/BirthdayProfile.java index 3742a8f..8fee006 100644 --- a/src/main/java/cc/fascinated/bat/features/birthday/profile/BirthdayProfile.java +++ b/src/main/java/cc/fascinated/bat/features/birthday/profile/BirthdayProfile.java @@ -1,5 +1,6 @@ package cc.fascinated.bat.features.birthday.profile; +import cc.fascinated.bat.common.ChannelUtils; import cc.fascinated.bat.common.Serializable; import cc.fascinated.bat.features.birthday.UserBirthday; import cc.fascinated.bat.model.BatGuild; @@ -157,7 +158,7 @@ public class BirthdayProfile extends Serializable { return; } - TextChannel channel = discordGuild.getTextChannelById(channelId); + TextChannel channel = ChannelUtils.getTextChannel(channelId); if (channel == null) { // this should never happen channelId = null; return; diff --git a/src/main/java/cc/fascinated/bat/features/logging/LogProfile.java b/src/main/java/cc/fascinated/bat/features/logging/LogProfile.java index a3d7db4..82d8335 100644 --- a/src/main/java/cc/fascinated/bat/features/logging/LogProfile.java +++ b/src/main/java/cc/fascinated/bat/features/logging/LogProfile.java @@ -41,7 +41,7 @@ public class LogProfile extends Serializable { return null; } // Ensure the channel exists - if (DiscordService.JDA.getTextChannelById(textChannel.getId()) == null) { + if (ChannelUtils.getTextChannel(textChannel.getId()) == null) { this.logChannels.remove(logType); return null; } diff --git a/src/main/java/cc/fascinated/bat/features/logging/command/ListSubCommand.java b/src/main/java/cc/fascinated/bat/features/logging/command/ListSubCommand.java index 30be465..8edc789 100644 --- a/src/main/java/cc/fascinated/bat/features/logging/command/ListSubCommand.java +++ b/src/main/java/cc/fascinated/bat/features/logging/command/ListSubCommand.java @@ -30,7 +30,7 @@ public class ListSubCommand extends BatSubCommand { Set the log channel for: - A specific event, use `/logs set ` - A specific category by using `/logs set ` - - All log types by using `/logs set all ` + - All log events by using `/logs set all ` To remove a log channel, it's the same as setting it, but with `/logs remove` instead of `/logs set`""", false); description.emptyLine(); diff --git a/src/main/java/cc/fascinated/bat/features/reminder/Reminder.java b/src/main/java/cc/fascinated/bat/features/reminder/Reminder.java index 5a10194..0d9569c 100644 --- a/src/main/java/cc/fascinated/bat/features/reminder/Reminder.java +++ b/src/main/java/cc/fascinated/bat/features/reminder/Reminder.java @@ -1,5 +1,6 @@ package cc.fascinated.bat.features.reminder; +import cc.fascinated.bat.common.ChannelUtils; import cc.fascinated.bat.service.DiscordService; import lombok.AllArgsConstructor; import lombok.Getter; @@ -42,6 +43,6 @@ public class Reminder { * @return The channel */ public TextChannel getChannel() { - return DiscordService.JDA.getTextChannelById(channelId); + return ChannelUtils.getTextChannel(channelId); } } diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/profile/guild/UserScoreFeedProfile.java b/src/main/java/cc/fascinated/bat/features/scoresaber/profile/guild/UserScoreFeedProfile.java index d88e50c..6c7a463 100644 --- a/src/main/java/cc/fascinated/bat/features/scoresaber/profile/guild/UserScoreFeedProfile.java +++ b/src/main/java/cc/fascinated/bat/features/scoresaber/profile/guild/UserScoreFeedProfile.java @@ -1,5 +1,6 @@ package cc.fascinated.bat.features.scoresaber.profile.guild; +import cc.fascinated.bat.common.ChannelUtils; import cc.fascinated.bat.common.Serializable; import cc.fascinated.bat.service.DiscordService; import com.google.gson.Gson; @@ -84,7 +85,7 @@ public class UserScoreFeedProfile extends Serializable { * @return the channel as a TextChannel */ public TextChannel getTextChannel() { - return DiscordService.JDA.getTextChannelById(channelId); + return ChannelUtils.getTextChannel(channelId); } @Override diff --git a/src/main/java/cc/fascinated/bat/features/welcomer/WelcomerProfile.java b/src/main/java/cc/fascinated/bat/features/welcomer/WelcomerProfile.java index b3555f7..c964d0d 100644 --- a/src/main/java/cc/fascinated/bat/features/welcomer/WelcomerProfile.java +++ b/src/main/java/cc/fascinated/bat/features/welcomer/WelcomerProfile.java @@ -1,5 +1,6 @@ package cc.fascinated.bat.features.welcomer; +import cc.fascinated.bat.common.ChannelUtils; import cc.fascinated.bat.common.Serializable; import cc.fascinated.bat.model.BatGuild; import cc.fascinated.bat.model.BatUser; @@ -111,7 +112,7 @@ public class WelcomerProfile extends Serializable { } String channelId = document.getString("channelId"); if (channelId != null) { - TextChannel textChannel = DiscordService.JDA.getTextChannelById(channelId); + TextChannel textChannel = ChannelUtils.getTextChannel(channelId); if (textChannel != null) { channel = textChannel; } diff --git a/src/main/java/cc/fascinated/bat/model/DiscordMessage.java b/src/main/java/cc/fascinated/bat/model/DiscordMessage.java index 1fc6839..3d22875 100644 --- a/src/main/java/cc/fascinated/bat/model/DiscordMessage.java +++ b/src/main/java/cc/fascinated/bat/model/DiscordMessage.java @@ -1,5 +1,7 @@ package cc.fascinated.bat.model; +import cc.fascinated.bat.common.ChannelUtils; +import cc.fascinated.bat.common.UserUtils; import cc.fascinated.bat.service.DiscordService; import lombok.AllArgsConstructor; import lombok.Getter; @@ -56,7 +58,7 @@ public class DiscordMessage { * @return the author */ public User getAuthor() { - return DiscordService.JDA.getUserById(this.authorId); + return UserUtils.getUser(this.authorId); } /** @@ -65,7 +67,7 @@ public class DiscordMessage { * @return the channel */ public TextChannel getChannel() { - return DiscordService.JDA.getTextChannelById(this.channelId); + return ChannelUtils.getTextChannel(this.channelId); } /**