From 54cd9014e71c47f081bdbfeca1a46e0141090fde Mon Sep 17 00:00:00 2001 From: horrible little slime <69secret69email69@gmail.com> Date: Fri, 1 Dec 2023 11:26:13 -0500 Subject: [PATCH] response to feedback --- src/commands/misc/rename.ts | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/commands/misc/rename.ts b/src/commands/misc/rename.ts index 3d63357..912f636 100644 --- a/src/commands/misc/rename.ts +++ b/src/commands/misc/rename.ts @@ -39,14 +39,17 @@ export async function execute(interaction: ChatInputCommandInteraction) { } const name = interaction.options.getString("name", true); - await discordClient.user?.setUsername(name); + const oaf = discordClient.user; - if (discordClient.user?.username === name) { - return void (await interaction.reply({ - content: `Done! My name is now ${name}`, - ephemeral: true, - })); - } else { + if (!oaf) { + return void (await discordClient.alert( + "Unfortunately, O.A.F. does not exist.", + )); + } + + await oaf.setUsername(name); + + if (oaf.username !== name) { discordClient.alert( `${interaction.user.username} tried to change O.A.F.'s name to ${name}, but failed!`, ); @@ -55,4 +58,9 @@ export async function execute(interaction: ChatInputCommandInteraction) { ephemeral: true, })); } + + return void (await interaction.reply({ + content: `Done! My name is now ${name}`, + ephemeral: true, + })); }