From 76fdb3b70fd31e479fe51408bfa05d7bb55d6671 Mon Sep 17 00:00:00 2001 From: themrrobert <10122432+themrrobert@users.noreply.github.com> Date: Wed, 28 Feb 2024 17:20:29 -0800 Subject: [PATCH] Add ability to remove custom tame icon (#57) --- src/mahoji/commands/tames.ts | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/mahoji/commands/tames.ts b/src/mahoji/commands/tames.ts index 78f136a2e1..e9d6802f4f 100644 --- a/src/mahoji/commands/tames.ts +++ b/src/mahoji/commands/tames.ts @@ -1993,10 +1993,12 @@ export const tamesCommand: OSBMahojiCommand = { description: 'The image to pick.', required: true, autocomplete: async () => { - return tameImageReplacementChoices.map(t => ({ + const options = tameImageReplacementChoices.map(t => ({ name: `${t.name} (${tameSpecies.find(s => s.id === t.species)!.name})`, value: t.name })); + options.unshift({ name: 'None', value: 'none' }); + return options; } } ] @@ -2075,12 +2077,31 @@ export const tamesCommand: OSBMahojiCommand = { if (user.perkTier() < PerkTier.Four) { return 'You need to be a Tier 3 patron to set a custom image for your tame.'; } + + // Handle resetting the custom image: + if (options.set_custom_image?.image.toLowerCase() === 'none') { + const { tame } = await getUsersTame(user); + if (tame === null) { + return "You don't have a tame selected, select the tame who's icon should be reset."; + } + await prisma.tame.update({ + where: { + id: tame.id + }, + data: { + custom_icon_id: null + } + }); + return 'Successfully removed the custom tame icon!'; + } + + // Handle updating the image: const replacement = tameImageReplacementChoices.find(i => i.name === options.set_custom_image?.image); if (!replacement) { return 'Invalid image.'; } const { tame } = await getUsersTame(user); - if (!tame) { + if (tame === null) { return "You don't have a tame selected, select the tame you want to give this icon."; } if (tame.species_id !== replacement.species) {