+48
packages/bot/src/modules/economy/commands/minecraft/shop/rm-item.ts
+48
packages/bot/src/modules/economy/commands/minecraft/shop/rm-item.ts
···
···
1
+
import { MessageFlags, SlashCommandSubcommandBuilder } from "discord.js";
2
+
import type { Command } from "@voidy/framework";
3
+
import { MinecraftShopItem } from "../../../schemas";
4
+
5
+
export default {
6
+
id: "minecraft.shop.rm-item",
7
+
devOnly: true,
8
+
data: new SlashCommandSubcommandBuilder()
9
+
.setName("rm-item")
10
+
.setDescription("Remove a Minecraft shop item from the database.")
11
+
.addStringOption((option) =>
12
+
option
13
+
.setName("item")
14
+
.setDescription("Minecraft item id (e.g. minecraft:diamond)")
15
+
.setRequired(true),
16
+
),
17
+
18
+
execute: async (interaction, _client) => {
19
+
await interaction.deferReply({ flags: [MessageFlags.Ephemeral] });
20
+
21
+
const item = interaction.options.getString("item", true);
22
+
23
+
try {
24
+
// Remove item from database, if it exists
25
+
const deleted = await MinecraftShopItem.findOneAndDelete({ item });
26
+
27
+
if (!deleted) {
28
+
await interaction.followUp({
29
+
content: `⚠️ Item \`${item}\` does not exist in the shop database.`,
30
+
flags: [MessageFlags.Ephemeral],
31
+
});
32
+
return;
33
+
}
34
+
35
+
await interaction.followUp({
36
+
content: `✅ Removed shop item \`${item}\` from the database.`,
37
+
flags: [MessageFlags.Ephemeral],
38
+
});
39
+
} catch (err) {
40
+
console.error("Failed to remove shop item:", err);
41
+
42
+
await interaction.followUp({
43
+
content: "❌ Failed to remove shop item. Check logs for details.",
44
+
flags: [MessageFlags.Ephemeral],
45
+
});
46
+
}
47
+
},
48
+
} as Command;