Skip to content

Commit

Permalink
CommandSlowmode - fix up log message
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaneBeee committed Jul 3, 2024
1 parent 132cdfe commit 76987b3
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ void onCommand(SlashCommandInteractionEvent event) {
int time = event.getOption("time").getAsInt();
OptionMapping timeOption = event.getOption("timeunit");
int timeU = timeOption != null ? timeOption.getAsInt() : 0;
Logger.info("TimeU: " + timeU);

TimeUnit timeUnit = switch (timeU) {
case 1 -> TimeUnit.MINUTES;
Expand All @@ -46,18 +45,25 @@ void onCommand(SlashCommandInteractionEvent event) {
if (channel instanceof ISlowmodeChannel textChannel) {
int seconds = (int) timeUnit.toSeconds(time);
String message;
String log;
if (seconds <= 0) {
seconds = 0;
message = "Slowmode **disabled**";
log = "Slowmode <red>disabled<reset>";
} else if (seconds > ISlowmodeChannel.MAX_SLOWMODE) {
seconds = ISlowmodeChannel.MAX_SLOWMODE;
message = "Slowmode set to **6 hours**";
log = "Slowmode set to <cyan>6 hours<reset>";
} else {
message = "Slowmode set to **" + time + " " + timeUnit.toString().toLowerCase(Locale.ROOT) + "**";
String timeSpan = time + " " + timeUnit.toString().toLowerCase(Locale.ROOT);
message = "Slowmode set to **" + timeSpan + "**";
log = "Slowmode set to <cyan>" + timeSpan + "<reset>";
}
message += " in **" + textChannel.getName() + "**";
log += " in <purple>" + textChannel.getName() + "<reset>";

String finalMessage = message;
Logger.info(log);
textChannel.getManager().setSlowmode(seconds).queue(
success -> event.getHook().editOriginal(finalMessage).queue(),
fail -> event.getHook().editOriginal("Failed").queue());
Expand Down

0 comments on commit 76987b3

Please sign in to comment.