counter not found is now an actual error that you can get

This commit is contained in:
Jill 2023-11-12 21:31:49 +03:00
parent 405c8b04b9
commit e65706c6f2
Signed by: oat
GPG Key ID: 33489AA58A955108
1 changed files with 13 additions and 7 deletions

View File

@ -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) {