From 38465f544d6987868980759b904c85ba0f677ad1 Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 9 Jul 2024 20:19:21 +0100 Subject: [PATCH] fix past tense --- .../base/commands/fun/EightBallCommand.java | 1 - .../moderation/punish/PunishmentProfile.java | 9 +++------ .../moderation/punish/PunishmentType.java | 18 ++++++++++++++---- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/java/cc/fascinated/bat/features/base/commands/fun/EightBallCommand.java b/src/main/java/cc/fascinated/bat/features/base/commands/fun/EightBallCommand.java index 4bf2598..19338c9 100644 --- a/src/main/java/cc/fascinated/bat/features/base/commands/fun/EightBallCommand.java +++ b/src/main/java/cc/fascinated/bat/features/base/commands/fun/EightBallCommand.java @@ -56,7 +56,6 @@ public class EightBallCommand extends BatCommand { } String response = responses[(int) (Math.random() * responses.length)]; - event.replyEmbeds(EmbedUtils.successEmbed() .setDescription("You asked: `%s`\n\n:8ball: The magic 8ball says: `%s`".formatted(question, response)) .build()) diff --git a/src/main/java/cc/fascinated/bat/features/moderation/punish/PunishmentProfile.java b/src/main/java/cc/fascinated/bat/features/moderation/punish/PunishmentProfile.java index 86fcdb9..f67392c 100644 --- a/src/main/java/cc/fascinated/bat/features/moderation/punish/PunishmentProfile.java +++ b/src/main/java/cc/fascinated/bat/features/moderation/punish/PunishmentProfile.java @@ -78,11 +78,10 @@ public class PunishmentProfile extends Serializable { .setDescription(punishmentDescription.build()) .build()); - String name = EnumUtils.getEnumName(type).endsWith("e") ? EnumUtils.getEnumName(type) + "d" : EnumUtils.getEnumName(type) + "ed"; user.getDiscordUser().openPrivateChannel().queue(channel -> { DescriptionBuilder descriptionBuilder = new DescriptionBuilder(null); descriptionBuilder.appendLine("🛡️ You have been **%s** in **%s**".formatted( - name, + type.getPastTense(), discordGuild.getName() ), false); if (length != -1 && (type == PunishmentType.MUTE || type == PunishmentType.BAN)) { @@ -289,13 +288,12 @@ public class PunishmentProfile extends Serializable { * @param length The length of the punishment */ public void punishmentResponse(SlashCommandInteraction event, PunishmentType type, BatUser targetUser, String reason, boolean remove, long length) { - String name = EnumUtils.getEnumName(type).endsWith("e") ? EnumUtils.getEnumName(type) + "d" : EnumUtils.getEnumName(type) + "ed"; DescriptionBuilder description = new DescriptionBuilder("Successfully %s%s %s".formatted( remove ? "Un-" : "", - name, + type.getPastTense(), targetUser.getDiscordUser().getAsMention() )); - description.appendLine("Reason: %s".formatted(reason == null ? "No reason provided" : reason), true); + description.appendLine("Reason: `%s`".formatted(reason == null ? "No reason provided" : reason), true); if (length != -1) { description.appendLine("Length: %s".formatted(TimeUtils.format(length)), true); } @@ -316,7 +314,6 @@ public class PunishmentProfile extends Serializable { public boolean canPunish(BatGuild guild, BatUser issuer, BatUser targetUser) { Member owner = guild.getDiscordGuild().getOwner(); assert owner != null; - if (targetUser == null) { return false; } diff --git a/src/main/java/cc/fascinated/bat/features/moderation/punish/PunishmentType.java b/src/main/java/cc/fascinated/bat/features/moderation/punish/PunishmentType.java index 7144ab0..b18a96c 100644 --- a/src/main/java/cc/fascinated/bat/features/moderation/punish/PunishmentType.java +++ b/src/main/java/cc/fascinated/bat/features/moderation/punish/PunishmentType.java @@ -1,11 +1,21 @@ package cc.fascinated.bat.features.moderation.punish; +import lombok.AllArgsConstructor; +import lombok.Getter; + /** * @author Fascinated (fascinated7) */ + +@AllArgsConstructor @Getter public enum PunishmentType { - KICK, - BAN, - WARN, - MUTE + KICK("Kicked"), + BAN("Banned"), + WARN("Warned"), + MUTE("Muted"); + + /** + * The past tense of the punishment + */ + private final String pastTense; }