Improved channel type check
This commit is contained in:
parent
5c66a0fe79
commit
df47c7a709
|
|
@ -73,21 +73,20 @@ public class CommandSetOutputChannel extends DiscordCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelType channelType = option.getChannelType();
|
ChannelType channelType = option.getChannelType();
|
||||||
switch (channelType) {
|
if (channelType.isMessage() || channelType.isThread()) {
|
||||||
case TEXT, NEWS, GUILD_NEWS_THREAD, GUILD_PUBLIC_THREAD, GUILD_PRIVATE_THREAD, FORUM -> {
|
GuildChannelUnion channel = option.getAsChannel();
|
||||||
GuildChannelUnion channel = option.getAsChannel();
|
boolean success = CommandOutputChannels.setOutputChannel(guild.getIdLong(), outputType, channel.getIdLong(), channelType);
|
||||||
boolean success = CommandOutputChannels.setOutputChannel(guild.getIdLong(), outputType, channel.getIdLong(), channelType);
|
if (success)
|
||||||
if (success)
|
event.replyEmbeds(Util.genericSuccessEmbed("Success", "Set channel " + channel.getAsMention() + " as the output channel for " + outputType.name() + "."))
|
||||||
event.replyEmbeds(Util.genericSuccessEmbed("Success", "Set channel " + channel.getAsMention() + " as the output channel for " + outputType.name() + "."))
|
.setEphemeral(true).queue(RestAction.getDefaultSuccess(), Util::handleFailure);
|
||||||
.setEphemeral(true).queue(RestAction.getDefaultSuccess(), Util::handleFailure);
|
else
|
||||||
else
|
event.replyEmbeds(Util.genericErrorEmbed("Error", "Unable to store the new channel output in the database"))
|
||||||
event.replyEmbeds(Util.genericErrorEmbed("Error", "Unable to store the new channel output in the database"))
|
.setEphemeral(true).queue(RestAction.getDefaultSuccess(), Util::handleFailure);
|
||||||
.setEphemeral(true).queue(RestAction.getDefaultSuccess(), Util::handleFailure);
|
}
|
||||||
}
|
else {
|
||||||
default -> event.replyEmbeds(Util.genericErrorEmbed("Error", "The channel type " + channelType.name() + " is not a valid output channel type"))
|
event.replyEmbeds(Util.genericErrorEmbed("Error", "The channel type " + channelType.name() + " is not a valid output channel type"))
|
||||||
.setEphemeral(true).queue(RestAction.getDefaultSuccess(), Util::handleFailure);
|
.setEphemeral(true).queue(RestAction.getDefaultSuccess(), Util::handleFailure);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user