Skip to content

Commit

Permalink
Merge branch 'bso' of github.com:gc/oldschoolbot-secret into bso
Browse files Browse the repository at this point in the history
  • Loading branch information
gc committed Mar 4, 2024
2 parents 995be69 + 76fdb3b commit 4e487dd
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/mahoji/commands/tames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
]
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 4e487dd

Please sign in to comment.