tangled
alpha
login
or
join now
thevoid.cafe
/
voidy
0
fork
atom
A powerful and extendable Discord bot, with it's own module system :3
thevoid.cafe/projects/voidy
0
fork
atom
overview
issues
pulls
pipelines
✨ Add rm-item command
Jo
2 months ago
f090890a
7f65dcfe
+48
1 changed file
expand all
collapse all
unified
split
packages
bot
src
modules
economy
commands
minecraft
shop
rm-item.ts
+48
packages/bot/src/modules/economy/commands/minecraft/shop/rm-item.ts
···
1
1
+
import { MessageFlags, SlashCommandSubcommandBuilder } from "discord.js";
2
2
+
import type { Command } from "@voidy/framework";
3
3
+
import { MinecraftShopItem } from "../../../schemas";
4
4
+
5
5
+
export default {
6
6
+
id: "minecraft.shop.rm-item",
7
7
+
devOnly: true,
8
8
+
data: new SlashCommandSubcommandBuilder()
9
9
+
.setName("rm-item")
10
10
+
.setDescription("Remove a Minecraft shop item from the database.")
11
11
+
.addStringOption((option) =>
12
12
+
option
13
13
+
.setName("item")
14
14
+
.setDescription("Minecraft item id (e.g. minecraft:diamond)")
15
15
+
.setRequired(true),
16
16
+
),
17
17
+
18
18
+
execute: async (interaction, _client) => {
19
19
+
await interaction.deferReply({ flags: [MessageFlags.Ephemeral] });
20
20
+
21
21
+
const item = interaction.options.getString("item", true);
22
22
+
23
23
+
try {
24
24
+
// Remove item from database, if it exists
25
25
+
const deleted = await MinecraftShopItem.findOneAndDelete({ item });
26
26
+
27
27
+
if (!deleted) {
28
28
+
await interaction.followUp({
29
29
+
content: `⚠️ Item \`${item}\` does not exist in the shop database.`,
30
30
+
flags: [MessageFlags.Ephemeral],
31
31
+
});
32
32
+
return;
33
33
+
}
34
34
+
35
35
+
await interaction.followUp({
36
36
+
content: `✅ Removed shop item \`${item}\` from the database.`,
37
37
+
flags: [MessageFlags.Ephemeral],
38
38
+
});
39
39
+
} catch (err) {
40
40
+
console.error("Failed to remove shop item:", err);
41
41
+
42
42
+
await interaction.followUp({
43
43
+
content: "❌ Failed to remove shop item. Check logs for details.",
44
44
+
flags: [MessageFlags.Ephemeral],
45
45
+
});
46
46
+
}
47
47
+
},
48
48
+
} as Command;