finish assigning and removing behaviors
This commit is contained in:
parent
ddb85d1d2f
commit
7a4b9e1726
|
@ -254,7 +254,26 @@ export default {
|
||||||
|
|
||||||
return await interaction.followUp(`${formatItem(item)} now has **${formatBehavior(behavior, value || undefined)}**`);
|
return await interaction.followUp(`${formatItem(item)} now has **${formatBehavior(behavior, value || undefined)}**`);
|
||||||
} else if (subcommand === 'remove') {
|
} else if (subcommand === 'remove') {
|
||||||
/////////////////// asngheasgyjdreajdneyonv
|
const behaviorName = interaction.options.getString('removebehavior', true);
|
||||||
|
|
||||||
|
const behavior = getBehavior(behaviorName);
|
||||||
|
if (!behavior) return await interaction.followUp(`No such behavior ${behaviorName}!`);
|
||||||
|
|
||||||
|
const existingBehavior = await db<ItemBehavior>('itemBehaviors')
|
||||||
|
.where('item', item.id)
|
||||||
|
.where('behavior', behavior.name)
|
||||||
|
.first();
|
||||||
|
|
||||||
|
if (!existingBehavior) {
|
||||||
|
return await interaction.followUp(`${formatItem(item)} does not have behavior \`${behaviorName}\`!`);
|
||||||
|
}
|
||||||
|
|
||||||
|
await db<ItemBehavior>('itemBehaviors')
|
||||||
|
.where('item', item.id)
|
||||||
|
.where('behavior', behavior.name)
|
||||||
|
.delete();
|
||||||
|
|
||||||
|
return await interaction.followUp(`Deleted behavior ${formatBehavior(behavior, existingBehavior.value)} from ${formatItem(item)}.`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (subcommand === 'give') {
|
if (subcommand === 'give') {
|
||||||
|
@ -320,6 +339,21 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
await interaction.respond(foundBehaviors.map(b => ({name: `${b.itemType}:${b.name} - ${b.description}`, value: b.name})));
|
await interaction.respond(foundBehaviors.map(b => ({name: `${b.itemType}:${b.name} - ${b.description}`, value: b.name})));
|
||||||
|
} else if (focused.name === 'removebehavior') {
|
||||||
|
const itemID = interaction.options.getString('customitem');
|
||||||
|
if (!itemID) return await interaction.respond([]);
|
||||||
|
const behaviors = await db<ItemBehavior>('itemBehaviors')
|
||||||
|
.where('item', itemID);
|
||||||
|
|
||||||
|
const foundBehaviors = behaviors
|
||||||
|
.map(b => ({ behavior: getBehavior(b.behavior)!, value: b.value }))
|
||||||
|
.filter(b => b.behavior)
|
||||||
|
.filter(b => b.behavior.name.toLowerCase().includes(focused.value.toLowerCase()));
|
||||||
|
|
||||||
|
await interaction.respond(foundBehaviors.map(b => ({
|
||||||
|
name: `${b.behavior.itemType}:${formatBehavior(b.behavior, b.value)} - ${b.behavior.description}`,
|
||||||
|
value: b.behavior.name
|
||||||
|
})));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} satisfies Command;
|
} satisfies Command;
|
Loading…
Reference in New Issue