From e65706c6f215f2c6883e4146983848c991e14feb Mon Sep 17 00:00:00 2001 From: "Jill \"oatmealine\" Monoids" Date: Sun, 12 Nov 2023 21:31:49 +0300 Subject: [PATCH] counter not found is now an actual error that you can get --- src/lib/counter.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/lib/counter.ts b/src/lib/counter.ts index 415a839..31ced73 100644 --- a/src/lib/counter.ts +++ b/src/lib/counter.ts @@ -85,14 +85,20 @@ export async function announceCounterUpdate(bot: Client, member: GuildMember, de } export async function changeCounterInteraction(interaction: CommandInteraction, member: GuildMember, amount: number, type: string) { - const counter = await getCounterData(type); + try { + const counter = await getCounterData(type); - const newCount = await changeCounter(amount, type); - await updateCounter(interaction.client, counter, newCount); - await announceCounterUpdate(interaction.client, member, amount, counter, newCount); - interaction.followUp({ - content: `${counter.emoji} **You have ${amount > 0 ? 'increased' : 'decreased'} the counter.**\n\`\`\`diff\n ${newCount - amount}\n${getSign(amount)}${Math.abs(amount)}\n ${newCount}\`\`\`` - }); + const newCount = await changeCounter(amount, type); + await updateCounter(interaction.client, counter, newCount); + await announceCounterUpdate(interaction.client, member, amount, counter, newCount); + interaction.followUp({ + content: `${counter.emoji} **You have ${amount > 0 ? 'increased' : 'decreased'} the counter.**\n\`\`\`diff\n ${newCount - amount}\n${getSign(amount)}${Math.abs(amount)}\n ${newCount}\`\`\`` + }); + } catch(err) { + interaction.followUp({ + content: (err as Error).toString() + }); + } } export async function counterAutocomplete(interaction: AutocompleteInteraction) {