spacecommands 3.2.4 → 3.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ module.exports = {
3
+ description: 'Deletes a slash command by name from Discord (Development Tool)',
4
+ category: 'Development',
5
+ minArgs: 1,
6
+ expectedArgs: '<command_name> [guild_id]',
7
+ ownerOnly: true,
8
+ testOnly: true, // Visible immediately
9
+ slash: 'both',
10
+ options: [
11
+ {
12
+ name: 'command_name',
13
+ description: 'The name of the command to delete (case insensitive)',
14
+ type: 3, // STRING
15
+ required: true,
16
+ },
17
+ {
18
+ name: 'scope',
19
+ description: 'Where to delete from',
20
+ type: 3, // STRING
21
+ required: false,
22
+ choices: [
23
+ { name: 'Global', value: 'global' },
24
+ { name: 'Current Server', value: 'guild' },
25
+ { name: 'All Servers (Dangerous)', value: 'all' }
26
+ ]
27
+ }
28
+ ],
29
+ callback: async (options) => {
30
+ const { instance, args, interaction, guild, client } = options;
31
+ const commandName = args[0].toLowerCase();
32
+ const scope = args[1] || 'global';
33
+ let deletedCount = 0;
34
+ let status = [];
35
+ // Helper to delete from a command manager
36
+ const deleteFromManager = async (manager, sourceName) => {
37
+ try {
38
+ const commands = await manager.fetch();
39
+ const cmd = commands.find((c) => c.name.toLowerCase() === commandName);
40
+ if (cmd) {
41
+ await manager.delete(cmd.id);
42
+ status.push(`✅ Deleted **${cmd.name}** from ${sourceName}`);
43
+ deletedCount++;
44
+ }
45
+ else {
46
+ // status.push(`⚠️ Could not find **${commandName}** in ${sourceName}`)
47
+ }
48
+ }
49
+ catch (err) {
50
+ status.push(`❌ Error handling ${sourceName}: ${err.message}`);
51
+ }
52
+ };
53
+ if (scope === 'global') {
54
+ await deleteFromManager(client.application?.commands, 'Global');
55
+ }
56
+ if (scope === 'guild' || scope === 'all') {
57
+ if (guild && scope === 'guild') {
58
+ await deleteFromManager(guild.commands, `Guild: ${guild.name}`);
59
+ }
60
+ else if (scope === 'all') {
61
+ // Iterate all guilds the bot is in
62
+ const guilds = client.guilds.cache;
63
+ status.push(`🔄 Scanning ${guilds.size} guilds...`);
64
+ for (const [id, g] of guilds) {
65
+ await deleteFromManager(g.commands, `Guild: ${g.name}`);
66
+ }
67
+ }
68
+ }
69
+ if (deletedCount === 0 && status.length === 0) {
70
+ return `Could not find any command named "${commandName}" to delete in scope "${scope}".`;
71
+ }
72
+ return status.join('\n') || `Operation complete. Deleted ${deletedCount} instances.`;
73
+ }
74
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spacecommands",
3
- "version": "3.2.4",
3
+ "version": "3.2.6",
4
4
  "main": "dist/index.js",
5
5
  "types": "./typings.d.ts",
6
6
  "typings": "./typings.d.ts",