forked from Fascinated/Bat
update the log remove command to be the same design as the set one
This commit is contained in:
parent
dbe6fb4762
commit
c284bb8a7f
@ -12,6 +12,7 @@ import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
@ -44,10 +45,14 @@ public class RemoveSubCommand extends BatSubCommand {
|
||||
for (LogType logType : LogType.values()) {
|
||||
profile.removeLogChannel(logType);
|
||||
}
|
||||
|
||||
event.replyEmbeds(EmbedUtils.successEmbed()
|
||||
.setDescription("%s Successfully removed the log channel for all log types".formatted(Emojis.CHECK_MARK_EMOJI))
|
||||
.build()).queue();
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder(null);
|
||||
description.appendLine("%s Successfully removed the log channel from `%s` log events".formatted(
|
||||
Emojis.CHECK_MARK_EMOJI,
|
||||
LogType.values().length
|
||||
), false);
|
||||
description.emptyLine();
|
||||
description.appendLine("*To view the current log channels, use `/logs list`*", false);
|
||||
event.replyEmbeds(EmbedUtils.successEmbed().setDescription(description.build()).build()).queue();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -55,25 +60,19 @@ public class RemoveSubCommand extends BatSubCommand {
|
||||
LogCategory logCategory = LogCategory.getLogCategory(type);
|
||||
if (logCategory != null) {
|
||||
List<LogType> category = LogType.getLogTypesByCategory(type);
|
||||
for (LogType logType : category) {
|
||||
profile.removeLogChannel(logType);
|
||||
}
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder(null);
|
||||
description.appendLine("%s Successfully removed the log channel for the `%s` category".formatted(
|
||||
description.appendLine("%s Successfully removed the log channel from `%s` `%s` log events".formatted(
|
||||
Emojis.CHECK_MARK_EMOJI,
|
||||
category.size(),
|
||||
logCategory.getName()
|
||||
), false);
|
||||
description.emptyLine();
|
||||
|
||||
int removed = 0;
|
||||
for (LogType logType : category) {
|
||||
if (!profile.hasLogChannel(logType)) {
|
||||
continue;
|
||||
}
|
||||
description.appendLine(logType.getName(), true);
|
||||
profile.removeLogChannel(logType);
|
||||
removed++;
|
||||
}
|
||||
|
||||
description.appendLine("*To view the current log channels, use `/logs list`*", false);
|
||||
event.replyEmbeds(EmbedUtils.successEmbed()
|
||||
.setDescription(removed == 0 ? "No log channels were removed for the `%s` category".formatted(logCategory.getName()) : description.build())
|
||||
.setDescription(description.build())
|
||||
.build()).queue();
|
||||
return;
|
||||
}
|
||||
@ -86,18 +85,14 @@ public class RemoveSubCommand extends BatSubCommand {
|
||||
.build()).queue();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!profile.hasLogChannel(logType)) {
|
||||
event.replyEmbeds(EmbedUtils.errorEmbed()
|
||||
.setDescription("The log channel for `%s` is not set".formatted(logType.getName()))
|
||||
.build()).queue();
|
||||
return;
|
||||
}
|
||||
profile.removeLogChannel(logType);
|
||||
event.replyEmbeds(EmbedUtils.successEmbed()
|
||||
.setDescription("%s Successfully removed the log channel for `%s`".formatted(
|
||||
event.replyEmbeds(EmbedUtils.successEmbed().setDescription(new EmbedDescriptionBuilder(null)
|
||||
.appendLine("%s Successfully removed the log channel from `%s`".formatted(
|
||||
Emojis.CHECK_MARK_EMOJI,
|
||||
logType.getName()
|
||||
)).build()).queue();
|
||||
), false)
|
||||
.emptyLine()
|
||||
.appendLine("*To view the current log channels, use `/logs list`*", false)
|
||||
.build()).build()).queue();
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class SetSubCommand extends BatSubCommand {
|
||||
profile.setLogChannel(logType, targetChannel);
|
||||
}
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder(null);
|
||||
description.appendLine("%s Successfully set the log channel for %s log events to %s".formatted(
|
||||
description.appendLine("%s Successfully set the log channel for `%s` log events to %s".formatted(
|
||||
Emojis.CHECK_MARK_EMOJI,
|
||||
LogType.values().length,
|
||||
targetChannel.getAsMention()
|
||||
@ -67,8 +67,11 @@ public class SetSubCommand extends BatSubCommand {
|
||||
LogCategory logCategory = LogCategory.getLogCategory(type);
|
||||
if (logCategory != null) {
|
||||
List<LogType> category = LogType.getLogTypesByCategory(type);
|
||||
for (LogType logType : category) {
|
||||
profile.setLogChannel(logType, targetChannel);
|
||||
}
|
||||
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder(null);
|
||||
description.appendLine("%s Successfully set the log channel for %s %s log events to %s".formatted(
|
||||
description.appendLine("%s Successfully set the log channel for `%s` `%s` log events to %s".formatted(
|
||||
Emojis.CHECK_MARK_EMOJI,
|
||||
category.size(),
|
||||
logCategory.getName(),
|
||||
@ -92,7 +95,7 @@ public class SetSubCommand extends BatSubCommand {
|
||||
}
|
||||
profile.setLogChannel(logType, targetChannel);
|
||||
event.replyEmbeds(EmbedUtils.successEmbed().setDescription(new EmbedDescriptionBuilder(null)
|
||||
.appendLine("%s Successfully set the log channel for %s to %s".formatted(
|
||||
.appendLine("%s Successfully set the log channel for `%s` to %s".formatted(
|
||||
Emojis.CHECK_MARK_EMOJI,
|
||||
logType.getName(),
|
||||
targetChannel.getAsMention()
|
||||
|
Loading…
x
Reference in New Issue
Block a user