@spatulox/simplediscordbot 1.0.1 → 1.0.3

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.
Files changed (40) hide show
  1. package/.env.example +1 -1
  2. package/LICENSE.md +21 -21
  3. package/README.md +45 -1
  4. package/dist/bot/Bot.js +10 -23
  5. package/dist/bot/BotEnv.js +2 -2
  6. package/dist/bot/BotLog.js +81 -37
  7. package/dist/bot/BotMessage.js +1 -1
  8. package/dist/cli/BaseCLI.js +1 -0
  9. package/dist/cli/MainCLI.js +0 -0
  10. package/dist/index.js +3 -1
  11. package/dist/manager/handlers/builder/ModalManager.js +113 -0
  12. package/dist/manager/handlers/interactions/BaseInteractionManager.js +338 -0
  13. package/dist/manager/handlers/interactions/InteractionManager.js +29 -0
  14. package/dist/manager/messages/EmbedManager.js +15 -8
  15. package/dist/utils/DiscordRegex.js +1 -0
  16. package/handlers/commands/README.md +11 -0
  17. package/handlers/commands/example.json +144 -0
  18. package/handlers/commands/example_v2.json +32 -0
  19. package/handlers/context_menu/example.json +24 -0
  20. package/handlers/modals/example.json +51 -0
  21. package/package.json +40 -40
  22. package/spatulox-simplediscordbot-1.0.1.tgz +0 -0
  23. package/dist/cli/GenerationCLI/InteractionGeneratorCLI.js +0 -20
  24. package/dist/cli/GenerationCLI.js +0 -36
  25. package/dist/cli/InputCLI.js +0 -25
  26. package/dist/cli/InteractionCLI.js +0 -109
  27. package/dist/manager/discord/ChannelManager.js +0 -48
  28. package/dist/manager/discord/DiscordRegex.js +0 -114
  29. package/dist/manager/discord/GuildManager.js +0 -67
  30. package/dist/manager/discord/InviteManager.js +0 -89
  31. package/dist/manager/discord/RoleManager.js +0 -83
  32. package/dist/manager/discord/UserManager.js +0 -69
  33. package/dist/manager/hadlers_old/builder/ModalManager.js +0 -111
  34. package/dist/manager/hadlers_old/builder/delete.js +0 -49
  35. package/dist/manager/hadlers_old/builder/deploy.js +0 -225
  36. package/dist/manager/hadlers_old/builder/interactions/CommandManager.js +0 -14
  37. package/dist/manager/hadlers_old/builder/interactions/ContextMenuManager.js +0 -14
  38. package/dist/manager/hadlers_old/builder/interactions/InteractionBase.js +0 -341
  39. package/dist/manager/hadlers_old/builder/interactions/InteractionManager.js +0 -65
  40. package/dist/manager/hadlers_old/builder/list.js +0 -166
@@ -1,341 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.InteractionBase = void 0;
7
- const discord_js_1 = require("discord.js");
8
- const readline_1 = __importDefault(require("readline"));
9
- const FileManager_1 = require("../../../FileManager");
10
- const Bot_1 = require("../../../../bot/Bot");
11
- const BotEnv_1 = require("../../../../bot/BotEnv");
12
- const Log_1 = require("../../../../utils/Log");
13
- class InteractionBase {
14
- constructor() {
15
- this.currentState = 'menu';
16
- this.deployFiles = [];
17
- this.rest = new discord_js_1.REST({ version: '10' }).setToken(BotEnv_1.BotEnv.token);
18
- this.rl = readline_1.default.createInterface({
19
- input: process.stdin,
20
- output: process.stdout
21
- });
22
- }
23
- /** 🚀 START INTERACTIF (100% automatique) */
24
- async startInteractive() {
25
- Log_1.Log.info('================================');
26
- console.clear();
27
- Log_1.Log.info(`${this.name}`);
28
- await this.showMenu();
29
- this.rl.prompt();
30
- this.rl.on('line', async (input) => {
31
- await this.handleInput(input.trim().toLowerCase());
32
- });
33
- this.rl.on('close', () => {
34
- Log_1.Log.info('👋 Au revoir !');
35
- process.exit(0);
36
- });
37
- }
38
- /** 🎛️ SINGLE INPUT HANDLER */
39
- async handleInput(input) {
40
- switch (this.currentState) {
41
- case 'menu':
42
- await this.handleMenuInput(input);
43
- break;
44
- case 'deploy_select':
45
- await this.handleDeploySelect(input);
46
- break;
47
- case 'delete_name':
48
- await this.handleDeleteName(input);
49
- break;
50
- case 'delete_all_confirm':
51
- await this.handleDeleteAllConfirm(input);
52
- break;
53
- }
54
- this.rl?.prompt();
55
- }
56
- /** 🎛️ MENU PRINCIPAL */
57
- async handleMenuInput(input) {
58
- const [action, arg] = input.split(' ');
59
- switch (action) {
60
- case 'deploy':
61
- await this.startDeployInteractive();
62
- break;
63
- case 'deploy-all':
64
- await this.deployAll();
65
- break;
66
- case 'list':
67
- await this.listAll();
68
- break;
69
- case 'list-guild':
70
- await this.listGuild(arg || '');
71
- break;
72
- case 'delete':
73
- this.startDeleteInteractive();
74
- break;
75
- case 'delete-all':
76
- this.startDeleteAllConfirm();
77
- break;
78
- case 'help':
79
- await this.showMenu();
80
- break;
81
- case 'exit':
82
- this.rl?.close();
83
- break;
84
- default:
85
- Log_1.Log.error('❌ Commande inconnue. Tapez "help"');
86
- }
87
- }
88
- /** 📁 START DEPLOY INTERACTIF */
89
- async startDeployInteractive() {
90
- const files = await FileManager_1.FileManager.listJsonFiles(`./handlers/${this.interactionHandlerFolder}`);
91
- if (!files) {
92
- Log_1.Log.error("Files not found!");
93
- return;
94
- }
95
- this.deployFiles = files;
96
- if (!this.deployFiles || this.deployFiles.length <= 0) {
97
- Log_1.Log.error("Files not found");
98
- return;
99
- }
100
- console.log(`\n📁 ${this.name} (${this.deployFiles.length} fichiers):`);
101
- console.log(' 0. ALL → Tout déployer');
102
- this.deployFiles.forEach((file, index) => {
103
- console.log(` ${index + 1}. ${file.replace('.json', '')}`);
104
- });
105
- console.log('');
106
- this.currentState = 'deploy_select';
107
- console.log('Choisir (numéro ou 0 pour tout): ');
108
- }
109
- /** 🔢 HANDLE DEPLOY CHOICE */
110
- async handleDeploySelect(input) {
111
- const num = parseInt(input);
112
- if (isNaN(num)) {
113
- Log_1.Log.error("❌ Numéro invalide");
114
- this.currentState = 'menu';
115
- await this.showMenu();
116
- return;
117
- }
118
- if (num === 0) {
119
- await this.deployAll();
120
- }
121
- else if (num > 0 && num <= this.deployFiles.length) {
122
- const selectedFile = this.deployFiles[num - 1];
123
- Log_1.Log.info(`🚀 Déploiement ${selectedFile}...`);
124
- const cmd = await FileManager_1.FileManager.readJsonFile(`./handlers/${this.interactionHandlerFolder}/${selectedFile}`);
125
- if (cmd) {
126
- const processed = await this.processPermissions(cmd);
127
- const globalCmds = await this.getGlobalCommands();
128
- await this.deploySingle(processed);
129
- await this.cleanup(globalCmds, [processed]);
130
- }
131
- }
132
- else {
133
- Log_1.Log.error(`❌ Choix ${num} invalide (1-${this.deployFiles.length} ou 0)`);
134
- this.currentState = 'menu';
135
- await this.showMenu();
136
- return;
137
- }
138
- this.currentState = 'menu';
139
- await this.showMenu();
140
- }
141
- /** 🗑️ START DELETE INTERACTIF */
142
- startDeleteInteractive() {
143
- console.log('\nNom de la commande: ');
144
- this.currentState = 'delete_name';
145
- }
146
- /** 🗑️ HANDLE DELETE NAME */
147
- async handleDeleteName(input) {
148
- await this.deleteCommand(input);
149
- this.currentState = 'menu';
150
- await this.showMenu();
151
- }
152
- /** 💥 START DELETE ALL CONFIRM */
153
- startDeleteAllConfirm() {
154
- console.log('\n⚠️ SUPPRIMER TOUT ? (yes/no): ');
155
- this.currentState = 'delete_all_confirm';
156
- }
157
- /** 💥 HANDLE DELETE ALL CONFIRM */
158
- async handleDeleteAllConfirm(input) {
159
- if (input.toLowerCase() === 'yes') {
160
- await this.deleteAllCommands();
161
- }
162
- this.currentState = 'menu';
163
- await this.showMenu();
164
- }
165
- /** 🚀 DÉPLOIER TOUT */
166
- async deployAll() {
167
- Log_1.Log.info(`🚀 Déploiement ${this.name}...`);
168
- await this.deployCommands([this.interactionHandlerFolder]);
169
- this.currentState = 'menu';
170
- await this.showMenu();
171
- }
172
- /** 📦 DÉPLOIEMENT BATCH */
173
- async deployCommands(paths) {
174
- const globalCmds = await this.getGlobalCommands();
175
- const localCommands = [];
176
- for (const path of paths) {
177
- const files = await FileManager_1.FileManager.listJsonFiles(`./handlers/${path}`);
178
- if (files == false || files.length <= 0) {
179
- Log_1.Log.error(`Aucun fichier dans ${path}`);
180
- return;
181
- }
182
- for (const file of files.filter(f => !f.includes('example'))) {
183
- const cmd = await FileManager_1.FileManager.readJsonFile(`./handlers/${path}/${file}`);
184
- if (!cmd)
185
- continue;
186
- const processed = await this.processPermissions(cmd);
187
- localCommands.push(processed);
188
- await this.deploySingle(processed);
189
- await this.delay(100);
190
- }
191
- }
192
- await this.cleanup(globalCmds, localCommands);
193
- }
194
- /** ⚡ DÉPLOYER UNE SEULE */
195
- async deploySingle(cmd) {
196
- const data = { ...cmd, guildID: undefined };
197
- if (cmd.type === 2 || cmd.type === 3)
198
- delete data.options;
199
- try {
200
- if (cmd.guildID?.length) {
201
- for (const guildId of cmd.guildID) {
202
- const guildCmds = await this.getGuildCommands(guildId);
203
- const existing = guildCmds.find(c => c.name === cmd.name && c.type === cmd.type);
204
- if (existing) {
205
- await this.rest.patch(discord_js_1.Routes.applicationGuildCommand(Bot_1.Bot.config.clientId, guildId, existing.id), { body: data });
206
- Log_1.Log.info(`🔄 MAJ ${cmd.name} → ${guildId.slice(-4)}`);
207
- }
208
- else {
209
- await this.rest.post(discord_js_1.Routes.applicationGuildCommands(Bot_1.Bot.config.clientId, guildId), { body: data });
210
- Log_1.Log.info(`✅ NEW ${cmd.name} → ${guildId.slice(-4)}`);
211
- }
212
- }
213
- }
214
- else {
215
- const globalCmds = await this.getGlobalCommands();
216
- const existing = globalCmds.find(c => c.name === cmd.name && c.type === cmd.type);
217
- if (existing) {
218
- await this.rest.patch(discord_js_1.Routes.applicationCommand(Bot_1.Bot.config.clientId, existing.id), { body: data });
219
- Log_1.Log.info(`🔄 MAJ ${cmd.name} → GLOBAL`);
220
- }
221
- else {
222
- await this.rest.post(discord_js_1.Routes.applicationCommands(Bot_1.Bot.config.clientId), { body: data });
223
- Log_1.Log.info(`✅ NEW ${cmd.name} → GLOBAL`);
224
- }
225
- }
226
- }
227
- catch (error) {
228
- Log_1.Log.error(`❌ ${cmd.name}: ${error}`);
229
- }
230
- }
231
- /** 📊 LISTE TOUT */
232
- async listAll() {
233
- const globalCmds = await this.getGlobalCommands();
234
- Log_1.Log.table([{ Type: `${this.name} GLOBAL`, Nombre: globalCmds.length }]);
235
- this.currentState = 'menu';
236
- await this.showMenu();
237
- }
238
- /** 📊 LISTE GUILDE */
239
- async listGuild(guildId) {
240
- if (!guildId) {
241
- Log_1.Log.error('ID guilde requis');
242
- this.currentState = 'menu';
243
- await this.showMenu();
244
- return;
245
- }
246
- const guildCmds = await this.getGuildCommands(guildId);
247
- Log_1.Log.table([{ Guilde: guildId.slice(-8), [`${this.name}`]: guildCmds.length }]);
248
- this.currentState = 'menu';
249
- await this.showMenu();
250
- }
251
- /** 📋 MENU PRINCIPAL */
252
- async showMenu() {
253
- console.log(`\n${this.name}:`);
254
- console.log(' deploy → Déployer spécifique');
255
- console.log(' deploy-all → Tout déployer/MAJ');
256
- console.log(' list → Lister toutes');
257
- console.log(' list-guild <id> → Lister guilde');
258
- console.log(' delete → Supprimer une');
259
- console.log(' delete-all → Tout supprimer');
260
- console.log(' help → Cette aide');
261
- console.log(' exit → Quitter\n');
262
- }
263
- // ... [Toutes les autres méthodes restent EXACTEMENT identiques] ...
264
- /** ⏱️ DELAY */
265
- async delay(ms) {
266
- return new Promise(r => setTimeout(r, ms));
267
- }
268
- /** 🌍 GLOBAL CMDS */
269
- async getGlobalCommands() {
270
- return this.rest.get(discord_js_1.Routes.applicationCommands(Bot_1.Bot.config.clientId));
271
- }
272
- /** 🏛️ GUILD CMDS */
273
- async getGuildCommands(guildId) {
274
- return this.rest.get(discord_js_1.Routes.applicationGuildCommands(Bot_1.Bot.config.clientId, guildId));
275
- }
276
- /** 🔐 PERMISSIONS */
277
- async processPermissions(cmd) {
278
- const processed = { ...cmd };
279
- if (cmd.default_member_permissions && Array.isArray(cmd.default_member_permissions)) {
280
- const bitfield = cmd.default_member_permissions
281
- .map(perm => BigInt(discord_js_1.PermissionFlagsBits[perm] || 0))
282
- .reduce((acc, val) => acc | val, BigInt(0));
283
- processed.default_member_permissions = Number(bitfield);
284
- }
285
- return processed;
286
- }
287
- /** 🗑️ DELETE UNE COMMANDE */
288
- async deleteCommand(name) {
289
- const globalCmds = await this.getGlobalCommands();
290
- const globalMatch = globalCmds.find(c => c.name === name);
291
- if (globalMatch) {
292
- await this.rest.delete(discord_js_1.Routes.applicationCommand(Bot_1.Bot.config.clientId, globalMatch.id));
293
- Log_1.Log.info(`✅ SUPPR GLOBAL ${name}`);
294
- }
295
- const botGuilds = Bot_1.Bot.client.guilds.cache.map(g => g.id);
296
- for (const guildId of botGuilds) {
297
- try {
298
- const guildCmds = await this.getGuildCommands(guildId);
299
- const guildMatch = guildCmds.find(c => c.name === name);
300
- if (guildMatch) {
301
- await this.rest.delete(discord_js_1.Routes.applicationGuildCommand(Bot_1.Bot.config.clientId, guildId, guildMatch.id));
302
- Log_1.Log.info(`✅ SUPPR ${name} → ${guildId.slice(-4)}`);
303
- }
304
- }
305
- catch {
306
- }
307
- }
308
- }
309
- /** 💥 DELETE TOUS */
310
- async deleteAllCommands() {
311
- const globalCmds = await this.getGlobalCommands();
312
- for (const cmd of globalCmds) {
313
- await this.rest.delete(discord_js_1.Routes.applicationCommand(Bot_1.Bot.config.clientId, cmd.id));
314
- Log_1.Log.info(`🗑️ SUPPR GLOBAL ${cmd.name}`);
315
- await this.delay(100);
316
- }
317
- const botGuilds = Bot_1.Bot.client.guilds.cache.map(g => g.id);
318
- for (const guildId of botGuilds) {
319
- try {
320
- const guildCmds = await this.getGuildCommands(guildId);
321
- for (const cmd of guildCmds) {
322
- await this.rest.delete(discord_js_1.Routes.applicationGuildCommand(Bot_1.Bot.config.clientId, guildId, cmd.id));
323
- Log_1.Log.info(`🗑️ SUPPR ${cmd.name} → ${guildId.slice(-4)}`);
324
- await this.delay(100);
325
- }
326
- }
327
- catch {
328
- }
329
- }
330
- Log_1.Log.info('✅ TOUT SUPPRIMÉ !');
331
- }
332
- /** 🧹 NETTOYAGE */
333
- async cleanup(globalCmds, localCmds) {
334
- const localNames = localCmds.map(c => `${c.name}_${c.type}`);
335
- for (const cmd of globalCmds.filter(c => !localNames.includes(`${c.name}_${c.type}`))) {
336
- await this.rest.delete(discord_js_1.Routes.applicationCommand(Bot_1.Bot.config.clientId, cmd.id));
337
- Log_1.Log.info(`🗑️ SUPPR ${cmd.name}`);
338
- }
339
- }
340
- }
341
- exports.InteractionBase = InteractionBase;
@@ -1,65 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- // src/discord/InteractionManager.ts
7
- const readline_1 = __importDefault(require("readline"));
8
- const CommandManager_1 = require("./CommandManager");
9
- const ContextMenuManager_1 = require("./ContextMenuManager");
10
- const Log_1 = require("../../../../utils/Log");
11
- class InteractionManager {
12
- static async start() {
13
- console.clear();
14
- Log_1.Log.info('🎛️ INTERACTION MANAGER');
15
- Log_1.Log.info('=====================');
16
- const rl = readline_1.default.createInterface({
17
- input: process.stdin,
18
- output: process.stdout
19
- });
20
- await this.showMainMenu(rl);
21
- rl.on('line', async (input) => {
22
- await this.handleMainMenu(input.trim().toLowerCase(), rl);
23
- });
24
- }
25
- static async showMainMenu(rl) {
26
- console.log('\n🎯 QUE VOULEZ-VOUS FAIRE ?');
27
- console.log(' 1. Slash Commands → npm run deploy:slash');
28
- console.log(' 2. Context Menus → npm run deploy:context');
29
- console.log(' 3. Tout déployer → npm run deploy:all');
30
- console.log(' help → Aide');
31
- console.log(' exit → Quitter\n');
32
- rl.prompt();
33
- }
34
- static async handleMainMenu(input, rl) {
35
- switch (input) {
36
- case '1':
37
- case 'slash':
38
- await new CommandManager_1.CommandManager().startInteractive();
39
- break;
40
- case '2':
41
- case 'context':
42
- await new ContextMenuManager_1.ContextMenuManager().startInteractive();
43
- break;
44
- case '3':
45
- case 'all':
46
- Log_1.Log.info('🚀 Déploiement complet...');
47
- await Promise.all([
48
- //new CommandManager().deployAll(),
49
- //new ContextMenuManager().deployAll()
50
- ]);
51
- break;
52
- case 'help':
53
- await this.showMainMenu(rl);
54
- break;
55
- case 'exit':
56
- Log_1.Log.info('👋 Au revoir !');
57
- rl.close();
58
- process.exit(0);
59
- default:
60
- Log_1.Log.error('❌ Choix invalide');
61
- rl.prompt();
62
- }
63
- }
64
- }
65
- InteractionManager.start();
@@ -1,166 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /*import { Routes } from 'discord-api-types/v10';
4
- import {Events} from "discord.js";
5
- import {Log} from "../../../utils/Log";
6
- import {client} from "../../../../src_example/client";
7
-
8
- export interface Command {
9
- name: string;
10
- description: string;
11
- options?: any[];
12
- default_member_permissions?: string | bigint | number;
13
- guildID?: string[];
14
- type: 1 | 2 | 3; // 1 = slash, 2 = user context, 3 = message context
15
- id?: string; // Discord API Command ID
16
- }
17
-
18
- export interface DiscordCommand extends Command {
19
- discordData?: any; // Données complètes depuis Discord API
20
- deployedGuilds: string[]; // Serveurs où la commande est déployée
21
- }
22
-
23
- export async function analyzeRegisteredCommands(): Promise<DiscordCommand[]> {
24
- if (!(await loginBot(client))) {
25
- Log.error("Impossible de connecter le bot");
26
- process.exit();
27
- }
28
-
29
- const allRegisteredCommands: DiscordCommand[] = [];
30
-
31
- client.once(Events.ClientReady, async () => {
32
- Log.info('Analyse des commandes enregistrées sur Discord');
33
-
34
- // 1. Récupérer TOUTES les commandes Discord du bot
35
- const globalDiscordCmds: any[] = await client.rest.get(
36
- Routes.applicationCommands(client.user!.id)
37
- ) as any[];
38
-
39
- // 2. Récupérer les commandes de TOUS les serveurs où le bot est présent
40
- const botGuilds = client.guilds.cache.map(guild => guild.id);
41
- const guildDiscordCmds: Record<string, any[]> = {};
42
-
43
- Log.info(`Analyse des ${botGuilds.length} serveurs où le bot est présent...`);
44
-
45
- for (const guildId of botGuilds) {
46
- try {
47
- const guildCmds = await client.rest.get(
48
- Routes.applicationGuildCommands(config.clientId, guildId)
49
- ) as any[];
50
- guildDiscordCmds[guildId] = guildCmds;
51
- Log.info((`Serveur ${guildId}: ${guildCmds.length} commandes guild`);
52
- } catch (error) {
53
- // Le bot n'a peut-être pas les permissions ou n'est pas dans ce serveur
54
- guildDiscordCmds[guildId] = [];
55
- }
56
- }
57
-
58
- // 3. Classer les commandes par nom et type
59
- const commandMap = new Map<string, DiscordCommand>();
60
-
61
- // Commandes globales
62
- for (const cmd of globalDiscordCmds) {
63
- const key = `${cmd.name}_${cmd.type}`;
64
- if (!commandMap.has(key)) {
65
- commandMap.set(key, {
66
- name: cmd.name,
67
- description: cmd.description || '',
68
- type: cmd.type,
69
- id: cmd.id,
70
- deployedGuilds: ['GLOBAL'],
71
- discordData: cmd
72
- });
73
- } else {
74
- const existing = commandMap.get(key)!;
75
- existing.deployedGuilds.push('GLOBAL');
76
- }
77
- }
78
-
79
- // Commandes par serveur
80
- for (const [guildId, guildCmds] of Object.entries(guildDiscordCmds)) {
81
- for (const cmd of guildCmds) {
82
- const key = `${cmd.name}_${cmd.type}`;
83
- if (!commandMap.has(key)) {
84
- commandMap.set(key, {
85
- name: cmd.name,
86
- description: cmd.description || '',
87
- type: cmd.type,
88
- id: cmd.id,
89
- deployedGuilds: [guildId],
90
- discordData: cmd
91
- });
92
- } else {
93
- const existing = commandMap.get(key)!;
94
- if (!existing.deployedGuilds.includes(guildId)) {
95
- existing.deployedGuilds.push(guildId);
96
- }
97
- }
98
- }
99
- } // ← Fermeture de la boucle for guildId
100
-
101
- // 4. Conversion en tableau et tri ← ✅ DÉPLACÉ ICI (CORRIGÉ)
102
- for (const [_key, cmd] of commandMap) {
103
- allRegisteredCommands.push(cmd);
104
- }
105
-
106
- allRegisteredCommands.sort((a, b) => {
107
- if (a.deployedGuilds.includes('GLOBAL') && !b.deployedGuilds.includes('GLOBAL')) return -1;
108
- if (!a.deployedGuilds.includes('GLOBAL') && b.deployedGuilds.includes('GLOBAL')) return 1;
109
- return a.name.localeCompare(b.name);
110
- });
111
-
112
- // 5. Affichage du classement
113
- console.log('\n' + '='.repeat(80));
114
- console.log('📋 CLASSEMENT DES COMMANDES ENREGISTRÉES SUR DISCORD');
115
- console.log('='.repeat(80));
116
-
117
- const globalCmds = allRegisteredCommands.filter(cmd => cmd.deployedGuilds.includes('GLOBAL'));
118
- const guildOnlyCmds = allRegisteredCommands.filter(cmd => !cmd.deployedGuilds.includes('GLOBAL'));
119
-
120
- console.log(`🌍 ${globalCmds.length} commandes GLOBALES`);
121
- console.log(`🏛️ ${guildOnlyCmds.length} commandes SERVEUR-SEUL`);
122
-
123
- // Tableau récapitulatif
124
- console.table(
125
- allRegisteredCommands.map(cmd => ({
126
- Nom: cmd.name,
127
- Type: cmd.type === 1 ? 'Slash' : cmd.type === 2 ? 'User Context' : 'Message Context',
128
- Serveurs: cmd.deployedGuilds.length > 3
129
- ? `${cmd.deployedGuilds.slice(0, 3).join(', ')}... (+${cmd.deployedGuilds.length - 3})`
130
- : cmd.deployedGuilds.join(', '),
131
- ID: cmd.id?.slice(-8) || 'N/A'
132
- }))
133
- );
134
-
135
- // Détails par catégorie
136
- if (globalCmds.length > 0) {
137
- console.log('\n🌍 COMMANDES GLOBALES:');
138
- globalCmds.forEach(cmd => {
139
- console.log(` • ${cmd.name} (ID: ${cmd.id?.slice(-8)}) - ${cmd.description}`);
140
- });
141
- }
142
-
143
- if (guildOnlyCmds.length > 0) {
144
- console.log('\n🏛️ COMMANDES SERVEUR-SEULEMENT:');
145
- const groupedByGuild = guildOnlyCmds.reduce((acc, cmd) => {
146
- for (const guildId of cmd.deployedGuilds) {
147
- if (!acc[guildId]) acc[guildId] = [];
148
- acc[guildId].push(cmd.name);
149
- }
150
- return acc;
151
- }, {} as Record<string, string[]>);
152
-
153
- for (const [guildId, cmds] of Object.entries(groupedByGuild)) {
154
- console.log(` 📂 Serveur ${guildId.slice(-8)}: ${cmds.join(', ')}`);
155
- }
156
- }
157
-
158
- console.log('\n✅ Analyse terminée!');
159
- process.exit();
160
- });
161
-
162
- return allRegisteredCommands;
163
- }
164
-
165
- // Utilisation
166
- analyzeRegisteredCommands();*/