diff --git a/src/commands/item.ts b/src/commands/item.ts index 1994962..89d0dcf 100644 --- a/src/commands/item.ts +++ b/src/commands/item.ts @@ -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('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('customItems') .where('id', item.id) .delete();