From 0600f13511a99dc20062c32ede048f444e2ea820 Mon Sep 17 00:00:00 2001 From: powermaker450 Date: Wed, 23 Oct 2024 16:07:27 -0400 Subject: [PATCH] Some cleanup again --- src/commands/confess.ts | 18 +++++++++++------- src/commands/confessmod.ts | 9 ++++++--- src/constants.ts | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/commands/confess.ts b/src/commands/confess.ts index 820ba29..0562567 100644 --- a/src/commands/confess.ts +++ b/src/commands/confess.ts @@ -54,7 +54,7 @@ export async function execute(interaction: ChatInputCommandInteraction) { // TODO: This all works as intended, but I'd like for it so be a reusable function // instead because all of this is used in src/main.ts const { id: guildId } = interaction.guild!; - const { id: userId } = interaction.user; + const { id: userId, displayName: userName } = interaction.user; try { // If the user is banned in this guild, don't let them post @@ -74,7 +74,7 @@ export async function execute(interaction: ChatInputCommandInteraction) { }); } - const confessChannel = dt.getGuildInfo(guildId)?.settings.confessChannel; + const confessChannel = dt.getGuildInfo(guildId)!.settings.confessChannel; const adminChannel = dt.getGuildInfo(guildId)?.settings.modChannel; const messageContent = `"${interaction.options.getString("message")}"`; @@ -163,8 +163,8 @@ export async function execute(interaction: ChatInputCommandInteraction) { dt.addConfession( message, messageId, - interaction.user.displayName, - interaction.user.id, + userName, + userId, messageContent, attachment ); @@ -173,14 +173,18 @@ export async function execute(interaction: ChatInputCommandInteraction) { // If there are 2 or more confessions, remove the previous confession's button components if (confessionsLength >= 2) { - await ( - BotClient.channels.cache.get(confessChannel!) as TextChannel - ).messages + (BotClient.channels.cache.get(confessChannel) as TextChannel).messages .fetch( dt.getGuildInfo(guildId)!.confessions[confessionsLength - 2].messageId ) .then(message => { message.edit({ components: [] }); + }) + .catch(err => { + logger.error( + "An error occured removing embeds from the previous message:", + err + ); }); } diff --git a/src/commands/confessmod.ts b/src/commands/confessmod.ts index 94505eb..39964a7 100644 --- a/src/commands/confessmod.ts +++ b/src/commands/confessmod.ts @@ -73,7 +73,7 @@ export const data = new SlashCommandBuilder() .setRequired(true) ) ) - .addSubcommand(pardonuser => + .addSubcommand(pardonuser => pardonuser .setName("pardonuser") .setDescription("Pardon a user from confessions") @@ -184,7 +184,10 @@ export async function execute(interaction: ChatInputCommandInteraction) { } // /confessmod pardon } else if (interaction.options.getSubcommand() === "pardon") { - const result = dt.removeBanById(guildId, interaction.options.getString("id")!); + const result = dt.removeBanById( + guildId, + interaction.options.getString("id")! + ); try { return result @@ -202,7 +205,7 @@ export async function execute(interaction: ChatInputCommandInteraction) { } else if (interaction.options.getSubcommand() === "pardonuser") { const { id: userId } = interaction.options.getUser("user")!; - const result = dt.removeBanByUser(guildId, userId); + const result = dt.removeBanByUser(guildId, userId); try { return result diff --git a/src/constants.ts b/src/constants.ts index 5273a1a..0503463 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,3 +1,3 @@ export const messageOpts = { ephemeral: true -} +};