Improved channel type check

This commit is contained in:
Teriuihi 2022-10-19 03:13:02 +02:00
parent 5c66a0fe79
commit df47c7a709

View File

@ -73,8 +73,7 @@ public class CommandSetOutputChannel extends DiscordCommand {
}
ChannelType channelType = option.getChannelType();
switch (channelType) {
case TEXT, NEWS, GUILD_NEWS_THREAD, GUILD_PUBLIC_THREAD, GUILD_PRIVATE_THREAD, FORUM -> {
if (channelType.isMessage() || channelType.isThread()) {
GuildChannelUnion channel = option.getAsChannel();
boolean success = CommandOutputChannels.setOutputChannel(guild.getIdLong(), outputType, channel.getIdLong(), channelType);
if (success)
@ -84,10 +83,10 @@ public class CommandSetOutputChannel extends DiscordCommand {
event.replyEmbeds(Util.genericErrorEmbed("Error", "Unable to store the new channel output in the database"))
.setEphemeral(true).queue(RestAction.getDefaultSuccess(), Util::handleFailure);
}
default -> event.replyEmbeds(Util.genericErrorEmbed("Error", "The channel type " + channelType.name() + " is not a valid output channel type"))
else {
event.replyEmbeds(Util.genericErrorEmbed("Error", "The channel type " + channelType.name() + " is not a valid output channel type"))
.setEphemeral(true).queue(RestAction.getDefaultSuccess(), Util::handleFailure);
}
}
@Override