item deletion + linked counter interaction fix. idk if it works but i don't wanna bother testing
This commit is contained in:
parent
f44f79a955
commit
c4980da8b7
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue