use the util for getting channels

This commit is contained in:
Lee 2024-07-04 03:52:33 +01:00
parent fa1f18e11b
commit 040c644ab1
8 changed files with 15 additions and 9 deletions

View File

@ -18,7 +18,7 @@ public class TextChannelUtils {
if (id == null) {
return false;
}
return DiscordService.JDA.getTextChannelById(id) != null;
return ChannelUtils.getTextChannel(id) != null;
}
/**

View File

@ -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;

View File

@ -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;
}

View File

@ -30,7 +30,7 @@ public class ListSubCommand extends BatSubCommand {
Set the log channel for:
- A specific event, use `/logs set <event> <channel>`
- A specific category by using `/logs set <category> <channel>`
- All log types by using `/logs set all <channel>`
- All log events by using `/logs set all <channel>`
To remove a log channel, it's the same as setting it,
but with `/logs remove` instead of `/logs set`""", false);
description.emptyLine();

View File

@ -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);
}
}

View File

@ -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

View File

@ -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;
}

View File

@ -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);
}
/**