make the log embeds more fancy
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 40s

This commit is contained in:
Lee 2024-07-04 06:44:55 +01:00
parent 4148f6e05f
commit c31ec09e0f
2 changed files with 26 additions and 14 deletions

@ -1,5 +1,6 @@
package cc.fascinated.bat.features.logging.command; package cc.fascinated.bat.features.logging.command;
import cc.fascinated.bat.Emojis;
import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.command.CommandInfo; import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedDescriptionBuilder; import cc.fascinated.bat.common.EmbedDescriptionBuilder;
@ -45,7 +46,7 @@ public class RemoveSubCommand extends BatSubCommand {
} }
event.replyEmbeds(EmbedUtils.successEmbed() event.replyEmbeds(EmbedUtils.successEmbed()
.setDescription("Successfully removed the log channel for all log types") .setDescription("%s Successfully removed the log channel for all log types".formatted(Emojis.CHECK_MARK_EMOJI))
.build()).queue(); .build()).queue();
return; return;
} }
@ -54,9 +55,11 @@ public class RemoveSubCommand extends BatSubCommand {
LogCategory logCategory = LogCategory.getLogCategory(type); LogCategory logCategory = LogCategory.getLogCategory(type);
if (logCategory != null) { if (logCategory != null) {
List<LogType> category = LogType.getLogTypesByCategory(type); List<LogType> category = LogType.getLogTypesByCategory(type);
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Log Channel"); EmbedDescriptionBuilder description = new EmbedDescriptionBuilder(null);
description.appendLine("Successfully removed the log channel for the `%s` category" description.appendLine("%s Successfully removed the log channel for the `%s` category".formatted(
.formatted(logCategory.getName()), false); Emojis.CHECK_MARK_EMOJI,
logCategory.getName()
), false);
description.emptyLine(); description.emptyLine();
int removed = 0; int removed = 0;
@ -79,7 +82,7 @@ public class RemoveSubCommand extends BatSubCommand {
LogType logType = LogType.getLogType(type); LogType logType = LogType.getLogType(type);
if (logType == null) { if (logType == null) {
event.replyEmbeds(EmbedUtils.errorEmbed() event.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("Invalid log type") .setDescription("%s Invalid log type".formatted(Emojis.CROSS_MARK_EMOJI))
.build()).queue(); .build()).queue();
return; return;
} }
@ -92,7 +95,9 @@ public class RemoveSubCommand extends BatSubCommand {
} }
profile.removeLogChannel(logType); profile.removeLogChannel(logType);
event.replyEmbeds(EmbedUtils.successEmbed() event.replyEmbeds(EmbedUtils.successEmbed()
.setDescription("Successfully removed the log channel for `%s`".formatted(logType.getName())) .setDescription("%s Successfully removed the log channel for `%s`".formatted(
.build()).queue(); Emojis.CHECK_MARK_EMOJI,
logType.getName()
)).build()).queue();
} }
} }

@ -1,5 +1,6 @@
package cc.fascinated.bat.features.logging.command; package cc.fascinated.bat.features.logging.command;
import cc.fascinated.bat.Emojis;
import cc.fascinated.bat.command.BatSubCommand; import cc.fascinated.bat.command.BatSubCommand;
import cc.fascinated.bat.command.CommandInfo; import cc.fascinated.bat.command.CommandInfo;
import cc.fascinated.bat.common.EmbedDescriptionBuilder; import cc.fascinated.bat.common.EmbedDescriptionBuilder;
@ -50,8 +51,12 @@ public class SetSubCommand extends BatSubCommand {
for (LogType logType : LogType.values()) { for (LogType logType : LogType.values()) {
profile.setLogChannel(logType, targetChannel); profile.setLogChannel(logType, targetChannel);
} }
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Log Channel"); EmbedDescriptionBuilder description = new EmbedDescriptionBuilder(null);
description.appendLine("Successfully set the log channel for %s log events to %s".formatted(LogType.values().length, targetChannel.getAsMention()), false); description.appendLine("%s Successfully set the log channel for %s log events to %s".formatted(
Emojis.CHECK_MARK_EMOJI,
LogType.values().length,
targetChannel.getAsMention()
), false);
description.emptyLine(); description.emptyLine();
description.appendLine("*To view the current log channels, use `/logs list`*", false); description.appendLine("*To view the current log channels, use `/logs list`*", false);
event.replyEmbeds(EmbedUtils.successEmbed().setDescription(description.build()).build()).queue(); event.replyEmbeds(EmbedUtils.successEmbed().setDescription(description.build()).build()).queue();
@ -62,8 +67,9 @@ public class SetSubCommand extends BatSubCommand {
LogCategory logCategory = LogCategory.getLogCategory(type); LogCategory logCategory = LogCategory.getLogCategory(type);
if (logCategory != null) { if (logCategory != null) {
List<LogType> category = LogType.getLogTypesByCategory(type); List<LogType> category = LogType.getLogTypesByCategory(type);
EmbedDescriptionBuilder description = new EmbedDescriptionBuilder("Log Channel"); EmbedDescriptionBuilder description = new EmbedDescriptionBuilder(null);
description.appendLine("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(), category.size(),
logCategory.getName(), logCategory.getName(),
targetChannel.getAsMention() targetChannel.getAsMention()
@ -80,13 +86,14 @@ public class SetSubCommand extends BatSubCommand {
LogType logType = LogType.getLogType(type); LogType logType = LogType.getLogType(type);
if (logType == null) { if (logType == null) {
event.replyEmbeds(EmbedUtils.errorEmbed() event.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("Invalid log type") .setDescription("%s Invalid log type".formatted(Emojis.CROSS_MARK_EMOJI))
.build()).queue(); .build()).queue();
return; return;
} }
profile.setLogChannel(logType, targetChannel); profile.setLogChannel(logType, targetChannel);
event.replyEmbeds(EmbedUtils.successEmbed().setDescription(new EmbedDescriptionBuilder("Log Channel") event.replyEmbeds(EmbedUtils.successEmbed().setDescription(new EmbedDescriptionBuilder(null)
.appendLine("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(), logType.getName(),
targetChannel.getAsMention() targetChannel.getAsMention()
), false) ), false)