File tree Expand file tree Collapse file tree 4 files changed +50
-1
lines changed Expand file tree Collapse file tree 4 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,18 @@ export default {
6363 const stringSelectMenu = client . stringSelectMenus . get ( interaction . customId ) ;
6464 if ( ! stringSelectMenu ) return ;
6565 try {
66- tringS . execute ( client , interaction ) ;
66+ stringSelectMenu . execute ( client , interaction ) ;
67+ } catch ( error ) {
68+ interaction . reply ( { content : 'There was an error while executing this select menu!' , ephemeral : true } ) ;
69+ console . log ( error ) ;
70+ }
71+ }
72+
73+ if ( interaction . isChannelSelectMenu ( ) ) {
74+ const channelSelectMenu = client . channelSelectMenus . get ( interaction . customId ) ;
75+ if ( ! channelSelectMenu ) return ;
76+ try {
77+ channelSelectMenu . execute ( client , interaction ) ;
6778 } catch ( error ) {
6879 interaction . reply ( { content : 'There was an error while executing this select menu!' , ephemeral : true } ) ;
6980 console . log ( error ) ;
Original file line number Diff line number Diff line change 1+ import { readdirSync } from 'fs' ;
2+ import chalk from 'chalk' ;
3+
4+ async function loadChannelSelectMenus ( client ) {
5+ client . channelSelectMenus . clear ( ) ;
6+ let files = 0 ;
7+ const channelSelectMenuFiles = readdirSync ( './src/interactions/channelSelectMenus' ) . filter ( file => file . endsWith ( '.js' ) ) ;
8+ if ( ! client . channelSelectMenus ) return ;
9+ for ( let i = 0 ; i < channelSelectMenuFiles . length ; i ++ ) {
10+ const channelSelectMenu = await import ( `../interactions/channelSelectMenus/${ channelSelectMenuFiles [ i ] } ?${ Date . now ( ) } ` ) ;
11+ await client . channelSelectMenus . set ( channelSelectMenu . default . id , channelSelectMenu . default ) ;
12+ console . log ( chalk . greenBright ( `[channelSelectMenu] Loaded ${ ( chalk . yellow ( channelSelectMenuFiles [ i ] ) ) } with channelSelectMenu ${ ( chalk . yellow ( channelSelectMenu . default . id ) ) } ` ) ) ;
13+ files ++ ;
14+ }
15+ const channelSelectMenuFolders = readdirSync ( './src/interactions/channelSelectMenus' , { withFileTypes : true } ) . filter ( file => file . isDirectory ( ) ) ;
16+ if ( ! channelSelectMenuFolders ) return ;
17+ for ( let i = 0 ; i < channelSelectMenuFolders . length ; i ++ ) {
18+ const channelSelectMenuFiles = readdirSync ( `./src/interactions/channelSelectMenus/${ channelSelectMenuFolders [ i ] . name } ` ) . filter ( file => file . endsWith ( '.js' ) ) ;
19+ for ( let j = 0 ; j < channelSelectMenuFiles . length ; j ++ ) {
20+ const channelSelectMenu = await import ( `../interactions/channelSelectMenus/${ selectMenuFolders [ i ] . name } /${ selectMenuFiles [ j ] } ?${ Date . now ( ) } ` ) ;
21+ await client . channelSelectMenus . set ( channelSelectMenu . default . id , channelSelectMenu . default ) ;
22+ console . log ( chalk . greenBright ( `[channelSelectMenu] Loaded ${ ( chalk . yellow ( channelSelectMenuFiles [ j ] ) ) } with channelSelectMenu ${ ( chalk . yellow ( channelSelectMenu . default . id ) ) } ` ) ) ;
23+ files ++ ;
24+ }
25+ }
26+ return files ;
27+ }
28+
29+ export default { loadChannelSelectMenus } ;
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import slashCommandHandler from './handlers/slashCommands.js';
77import modalHandler from './handlers/modals.js' ;
88import buttonHandler from './handlers/buttons.js' ;
99import stringSelectMenuHandler from './handlers/stringSelectMenus.js' ;
10+ import channelSelectMenuHandler from './handlers/channelSelectMenus.js' ;
1011import contextMenus from './handlers/contextMenus.js' ;
1112import register from './handlers/register.js' ;
1213
@@ -34,6 +35,7 @@ client.slashCommands = new Discord.Collection();
3435client . modals = new Discord . Collection ( ) ;
3536client . buttons = new Discord . Collection ( ) ;
3637client . stringSelectMenus = new Discord . Collection ( ) ;
38+ client . channelSelectMenus = new Discord . Collection ( ) ;
3739client . contextMenus = new Discord . Collection ( ) ;
3840
3941await eventHandler . loadEvents ( client ) ;
@@ -42,6 +44,7 @@ await slashCommandHandler.loadSlashCommands(client);
4244await modalHandler . loadModals ( client ) ;
4345await buttonHandler . loadButtons ( client ) ;
4446await stringSelectMenuHandler . loadStringSelectMenus ( client ) ;
47+ await channelSelectMenuHandler . loadChannelSelectMenus ( client ) ;
4548await contextMenus . loadContextMenus ( client ) ;
4649await register . load ( client ) ;
4750
Original file line number Diff line number Diff line change 1+ export default {
2+ id : 'test' ,
3+ async execute ( client , interaction ) {
4+ interaction . reply ( 'Hello World!' ) ;
5+ }
6+ } ;
You can’t perform that action at this time.
0 commit comments