Skip to content

Commit b8ea760

Browse files
committed
added stringSelectMenus
1 parent f266173 commit b8ea760

File tree

4 files changed

+32
-32
lines changed

4 files changed

+32
-32
lines changed

src/handlers/selectMenus.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/handlers/stringSelectMenus.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { readdirSync } from 'fs';
2+
import chalk from 'chalk';
3+
4+
async function loadStringSelectMenus(client) {
5+
client.stringSelectMenus.clear();
6+
let files = 0;
7+
const stringSelectMenuFiles = readdirSync('./src/interactions/stringSelectMenus').filter(file => file.endsWith('.js'));
8+
if (!client.stringSelectMenus) return;
9+
for (let i = 0; i < stringSelectMenuFiles.length; i++) {
10+
const stringSelectMenu = await import(`../interactions/stringSelectMenus/${stringSelectMenuFiles[i]}?${Date.now()}`);
11+
await client.stringSelectMenus.set(stringSelectMenu.default.id, stringSelectMenu.default);
12+
console.log(chalk.greenBright(`[STRINGSELECTMENU] Loaded ${(chalk.yellow(stringSelectMenuFiles[i]))} with stringSelectMenu ${(chalk.yellow(stringSelectMenu.default.id))}`));
13+
files++;
14+
}
15+
const stringSelectMenuFolders = readdirSync('./src/interactions/stringSelectMenus', { withFileTypes: true }).filter(file => file.isDirectory());
16+
if (!stringSelectMenuFolders) return;
17+
for (let i = 0; i < stringSelectMenuFolders.length; i++) {
18+
const stringSelectMenuFiles = readdirSync(`./src/interactions/stringSelectMenus/${stringSelectMenuFolders[i].name}`).filter(file => file.endsWith('.js'));
19+
for (let j = 0; j < stringSelectMenuFiles.length; j++) {
20+
const stringSelectMenu = await import(`../interactions/stringSelectMenus/${selectMenuFolders[i].name}/${selectMenuFiles[j]}?${Date.now()}`);
21+
await client.stringSelectMenus.set(stringSelectMenu.default.id, stringSelectMenu.default);
22+
console.log(chalk.greenBright(`[STRINGSELECTMENU] Loaded ${(chalk.yellow(stringSelectMenuFiles[j]))} with stringSelectMenu ${(chalk.yellow(stringSelectMenu.default.id))}`));
23+
files++;
24+
}
25+
}
26+
return files;
27+
}
28+
29+
export default { loadStringSelectMenus };

src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import messageCommandHandler from './handlers/messageCommands.js';
66
import slashCommandHandler from './handlers/slashCommands.js';
77
import modalHandler from './handlers/modals.js';
88
import buttonHandler from './handlers/buttons.js';
9-
import selectMenuHandler from './handlers/selectMenus.js';
9+
import stringSelectMenuHandler from './handlers/stringSelectMenus.js';
1010
import contextMenus from './handlers/contextMenus.js';
1111
import register from './handlers/register.js';
1212

@@ -33,15 +33,15 @@ client.messageCommandsAliases = new Discord.Collection();
3333
client.slashCommands = new Discord.Collection();
3434
client.modals = new Discord.Collection();
3535
client.buttons = new Discord.Collection();
36-
client.selectMenus = new Discord.Collection();
36+
client.stringSelectMenus = new Discord.Collection();
3737
client.contextMenus = new Discord.Collection();
3838

3939
await eventHandler.loadEvents(client);
4040
await messageCommandHandler.loadMessageCommands(client);
4141
await slashCommandHandler.loadSlashCommands(client);
4242
await modalHandler.loadModals(client);
4343
await buttonHandler.loadButtons(client);
44-
await selectMenuHandler.loadSelectMenus(client);
44+
await stringSelectMenuHandler.loadStringSelectMenus(client);
4545
await contextMenus.loadContextMenus(client);
4646
await register.load(client);
4747

File renamed without changes.

0 commit comments

Comments
 (0)