item deletion + linked counter interaction fix. idk if it works but i don't wanna bother testing

This commit is contained in:
Jill 2023-11-21 23:31:00 +03:00
parent f44f79a955
commit c4980da8b7
Signed by: oat
GPG Key ID: 33489AA58A955108
1 changed files with 8 additions and 1 deletions

View File

@ -1,5 +1,5 @@
import { AutocompleteInteraction, CommandInteraction, SlashCommandBuilder } from 'discord.js';
import { CustomCraftingRecipeItem, CustomItem, db } from '../lib/db';
import { Counter, CustomCraftingRecipeItem, CustomItem, db } from '../lib/db';
import { customItemAutocomplete, formatItem, formatItems, getItem, giveItem, itemAutocomplete } from '../lib/rpg/items';
import { behaviors } from '../lib/rpg/behaviors';
import { Command } from '../types/index';
@ -236,6 +236,13 @@ export default {
return interaction.followUp(`⚠️ This item is used in the following recipes:\n${recipes.map(r => `- ${formatRecipe(r!)}`).join('\n')}`);
}
const linkedWith = await db<Counter>('counters')
.where('linkedItem', item.id);
if (linkedWith.length > 0) {
return interaction.followUp(`⚠️ This item is used in the following counters:\n${linkedWith.map(c => `- ${c.key} ${c.value} in <#${c.channel}>`).join('\n')}`);
}
await db<CustomItem>('customItems')
.where('id', item.id)
.delete();