diff --git a/src/components/moderation/ban.ts b/src/components/moderation/ban.ts index 0c25f36c..a4c205be 100644 --- a/src/components/moderation/ban.ts +++ b/src/components/moderation/ban.ts @@ -114,8 +114,9 @@ export default class Ban extends ModerationComponent { removed: null, expunged: null, }; + await this.notify_user(command, user, "banned", moderation); await this.register_new_moderation(moderation); - await this.notify(command, user, "banned", moderation); + await this.reply_with_success(command, user, "banned"); } catch (e) { await this.reply_with_error(command, "Error banning"); critical_error(e); @@ -143,7 +144,7 @@ export default class Ban extends ModerationComponent { } else { await this.remove_moderation(res.value); this.sleep_list.remove(res.value._id); - await this.notify(command, user, "unbanned", res.value, true); + await this.reply_with_success(command, user, "unbanned"); } } catch (e) { await this.reply_with_error(command, "Error unbanning"); diff --git a/src/components/moderation/kick.ts b/src/components/moderation/kick.ts index 37a00916..23a55ddc 100644 --- a/src/components/moderation/kick.ts +++ b/src/components/moderation/kick.ts @@ -69,7 +69,7 @@ export default class Kick extends ModerationComponent { expunged: null, }; await this.register_new_moderation(moderation); - await this.notify(command, user, "kicked", moderation); + await this.reply_and_notify(command, user, "kicked", moderation); } catch (e) { await this.reply_with_error(command, "Error kicking"); critical_error(e); diff --git a/src/components/moderation/moderation-common.ts b/src/components/moderation/moderation-common.ts index ad1d4444..561b001e 100644 --- a/src/components/moderation/moderation-common.ts +++ b/src/components/moderation/moderation-common.ts @@ -249,13 +249,7 @@ export abstract class ModerationComponent extends BotComponent { } } - async notify( - command: TextBasedCommand, - user: Discord.User, - action: string, - moderation: Omit, - is_removal = false, - ) { + async reply_with_success(command: TextBasedCommand, user: Discord.User, action: string) { await command.reply({ embeds: [ new Discord.EmbedBuilder() @@ -263,6 +257,15 @@ export abstract class ModerationComponent extends BotComponent { .setDescription(`<:success:1138616548630745088> ***${user.displayName} was ${action}***`), ], }); + } + + async notify_user( + command: TextBasedCommand, + user: Discord.User, + action: string, + moderation: Omit, + is_removal = false, + ) { const duration = moderation.duration ? time_to_human(moderation.duration) : "Permanent"; try { await ( @@ -288,4 +291,15 @@ export abstract class ModerationComponent extends BotComponent { critical_error(e); } } + + async reply_and_notify( + command: TextBasedCommand, + user: Discord.User, + action: string, + moderation: Omit, + is_removal = false, + ) { + await this.reply_with_success(command, user, action); + await this.notify_user(command, user, action, moderation, is_removal); + } } diff --git a/src/components/moderation/mute.ts b/src/components/moderation/mute.ts index 4c454ac1..5dbd94f1 100644 --- a/src/components/moderation/mute.ts +++ b/src/components/moderation/mute.ts @@ -107,7 +107,7 @@ export default class Mute extends ModerationComponent { expunged: null, }; await this.register_new_moderation(moderation); - await this.notify(command, user, "muted", moderation); + await this.reply_and_notify(command, user, "muted", moderation); } catch (e) { await this.reply_with_error(command, "Error applying mute"); critical_error(e); @@ -135,7 +135,7 @@ export default class Mute extends ModerationComponent { } else { await this.remove_moderation(res.value); this.sleep_list.remove(res.value._id); - await this.notify(command, user, "unmuted", res.value, true); + await this.reply_and_notify(command, user, "unmuted", res.value, true); } } catch (e) { await this.reply_with_error(command, "Error unmuting");