File tree Expand file tree Collapse file tree 4 files changed +49
-0
lines changed Expand file tree Collapse file tree 4 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,17 @@ export default {
8080 console . log ( error ) ;
8181 }
8282 }
83+
84+ if ( interaction . isMentionableSelectMenu ( ) ) {
85+ const mentionableSelectMenu = client . mentionableSelectMenus . get ( interaction . customId ) ;
86+ if ( ! mentionableSelectMenu ) return ;
87+ try {
88+ mentionableSelectMenu . execute ( client , interaction ) ;
89+ } catch ( error ) {
90+ interaction . reply ( { content : 'There was an error while executing this select menu!' , ephemeral : true } ) ;
91+ console . log ( error ) ;
92+ }
93+ }
8394
8495 } catch ( error ) {
8596 return 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 loadMentionableSelectMenus ( client ) {
5+ client . mentionableSelectMenus . clear ( ) ;
6+ let files = 0 ;
7+ const mentionableSelectMenuFiles = readdirSync ( './src/interactions/mentionableSelectMenus' ) . filter ( file => file . endsWith ( '.js' ) ) ;
8+ if ( ! client . mentionableSelectMenus ) return ;
9+ for ( let i = 0 ; i < mentionableSelectMenuFiles . length ; i ++ ) {
10+ const mentionableSelectMenu = await import ( `../interactions/mentionableSelectMenus/${ mentionableSelectMenuFiles [ i ] } ?${ Date . now ( ) } ` ) ;
11+ await client . mentionableSelectMenus . set ( mentionableSelectMenu . default . id , mentionableSelectMenu . default ) ;
12+ console . log ( chalk . greenBright ( `[mentionableSelectMenu] Loaded ${ ( chalk . yellow ( mentionableSelectMenuFiles [ i ] ) ) } with mentionableSelectMenu ${ ( chalk . yellow ( mentionableSelectMenu . default . id ) ) } ` ) ) ;
13+ files ++ ;
14+ }
15+ const mentionableSelectMenuFolders = readdirSync ( './src/interactions/mentionableSelectMenus' , { withFileTypes : true } ) . filter ( file => file . isDirectory ( ) ) ;
16+ if ( ! mentionableSelectMenuFolders ) return ;
17+ for ( let i = 0 ; i < mentionableSelectMenuFolders . length ; i ++ ) {
18+ const mentionableSelectMenuFiles = readdirSync ( `./src/interactions/mentionableSelectMenus/${ mentionableSelectMenuFolders [ i ] . name } ` ) . filter ( file => file . endsWith ( '.js' ) ) ;
19+ for ( let j = 0 ; j < mentionableSelectMenuFiles . length ; j ++ ) {
20+ const mentionableSelectMenu = await import ( `../interactions/mentionableSelectMenus/${ selectMenuFolders [ i ] . name } /${ selectMenuFiles [ j ] } ?${ Date . now ( ) } ` ) ;
21+ await client . mentionableSelectMenus . set ( mentionableSelectMenu . default . id , mentionableSelectMenu . default ) ;
22+ console . log ( chalk . greenBright ( `[mentionableSelectMenu] Loaded ${ ( chalk . yellow ( mentionableSelectMenuFiles [ j ] ) ) } with mentionableSelectMenu ${ ( chalk . yellow ( mentionableSelectMenu . default . id ) ) } ` ) ) ;
23+ files ++ ;
24+ }
25+ }
26+ return files ;
27+ }
28+
29+ export default { loadMentionableSelectMenus } ;
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import modalHandler from './handlers/modals.js';
88import buttonHandler from './handlers/buttons.js' ;
99import stringSelectMenuHandler from './handlers/stringSelectMenus.js' ;
1010import channelSelectMenuHandler from './handlers/channelSelectMenus.js' ;
11+ import mentionableSelectMenuHandler from './handlers/mentionableSelectMenus.js' ;
1112import contextMenus from './handlers/contextMenus.js' ;
1213import register from './handlers/register.js' ;
1314
@@ -36,6 +37,7 @@ client.modals = new Discord.Collection();
3637client . buttons = new Discord . Collection ( ) ;
3738client . stringSelectMenus = new Discord . Collection ( ) ;
3839client . channelSelectMenus = new Discord . Collection ( ) ;
40+ client . mentionableSelectMenus = new Discord . Collection ( ) ;
3941client . contextMenus = new Discord . Collection ( ) ;
4042
4143await eventHandler . loadEvents ( client ) ;
@@ -45,6 +47,7 @@ await modalHandler.loadModals(client);
4547await buttonHandler . loadButtons ( client ) ;
4648await stringSelectMenuHandler . loadStringSelectMenus ( client ) ;
4749await channelSelectMenuHandler . loadChannelSelectMenus ( client ) ;
50+ await mentionableSelectMenuHandler . loadMentionableSelectMenus ( client ) ;
4851await contextMenus . loadContextMenus ( client ) ;
4952await register . load ( client ) ;
5053
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