File tree Expand file tree Collapse file tree 7 files changed +47
-4
lines changed Expand file tree Collapse file tree 7 files changed +47
-4
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,17 @@ export default {
102102 console . log ( error ) ;
103103 }
104104 }
105+
106+ if ( interaction . isUserSelectMenu ( ) ) {
107+ const userSelectMenu = client . userSelectMenus . get ( interaction . customId ) ;
108+ if ( ! userSelectMenu ) return ;
109+ try {
110+ userSelectMenu . execute ( client , interaction ) ;
111+ } catch ( error ) {
112+ interaction . reply ( { content : 'There was an error while executing this select menu!' , ephemeral : true } ) ;
113+ console . log ( error ) ;
114+ }
115+ }
105116
106117 } catch ( error ) {
107118 return console . log ( error ) ;
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ async function loadChannelSelectMenus(client) {
1717 for ( let i = 0 ; i < channelSelectMenuFolders . length ; i ++ ) {
1818 const channelSelectMenuFiles = readdirSync ( `./src/interactions/channelSelectMenus/${ channelSelectMenuFolders [ i ] . name } ` ) . filter ( file => file . endsWith ( '.js' ) ) ;
1919 for ( let j = 0 ; j < channelSelectMenuFiles . length ; j ++ ) {
20- const channelSelectMenu = await import ( `../interactions/channelSelectMenus/${ selectMenuFolders [ i ] . name } /${ selectMenuFiles [ j ] } ?${ Date . now ( ) } ` ) ;
20+ const channelSelectMenu = await import ( `../interactions/channelSelectMenus/${ channelSelectMenuFolders [ i ] . name } /${ channelSelectMenuFiles [ j ] } ?${ Date . now ( ) } ` ) ;
2121 await client . channelSelectMenus . set ( channelSelectMenu . default . id , channelSelectMenu . default ) ;
2222 console . log ( chalk . greenBright ( `[channelSelectMenu] Loaded ${ ( chalk . yellow ( channelSelectMenuFiles [ j ] ) ) } with channelSelectMenu ${ ( chalk . yellow ( channelSelectMenu . default . id ) ) } ` ) ) ;
2323 files ++ ;
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ async function loadMentionableSelectMenus(client) {
1717 for ( let i = 0 ; i < mentionableSelectMenuFolders . length ; i ++ ) {
1818 const mentionableSelectMenuFiles = readdirSync ( `./src/interactions/mentionableSelectMenus/${ mentionableSelectMenuFolders [ i ] . name } ` ) . filter ( file => file . endsWith ( '.js' ) ) ;
1919 for ( let j = 0 ; j < mentionableSelectMenuFiles . length ; j ++ ) {
20- const mentionableSelectMenu = await import ( `../interactions/mentionableSelectMenus/${ selectMenuFolders [ i ] . name } /${ selectMenuFiles [ j ] } ?${ Date . now ( ) } ` ) ;
20+ const mentionableSelectMenu = await import ( `../interactions/mentionableSelectMenus/${ mentionableSelectMenuFolders [ i ] . name } /${ mentionableSelectMenuFiles [ j ] } ?${ Date . now ( ) } ` ) ;
2121 await client . mentionableSelectMenus . set ( mentionableSelectMenu . default . id , mentionableSelectMenu . default ) ;
2222 console . log ( chalk . greenBright ( `[mentionableSelectMenu] Loaded ${ ( chalk . yellow ( mentionableSelectMenuFiles [ j ] ) ) } with mentionableSelectMenu ${ ( chalk . yellow ( mentionableSelectMenu . default . id ) ) } ` ) ) ;
2323 files ++ ;
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ async function loadRoleSelectMenus(client) {
1717 for ( let i = 0 ; i < roleSelectMenuFolders . length ; i ++ ) {
1818 const roleSelectMenuFiles = readdirSync ( `./src/interactions/roleSelectMenus/${ roleSelectMenuFolders [ i ] . name } ` ) . filter ( file => file . endsWith ( '.js' ) ) ;
1919 for ( let j = 0 ; j < roleSelectMenuFiles . length ; j ++ ) {
20- const roleSelectMenu = await import ( `../interactions/roleSelectMenus/${ selectMenuFolders [ i ] . name } /${ selectMenuFiles [ j ] } ?${ Date . now ( ) } ` ) ;
20+ const roleSelectMenu = await import ( `../interactions/roleSelectMenus/${ roleSelectMenuFolders [ i ] . name } /${ roleSelectMenuFiles [ j ] } ?${ Date . now ( ) } ` ) ;
2121 await client . roleSelectMenus . set ( roleSelectMenu . default . id , roleSelectMenu . default ) ;
2222 console . log ( chalk . greenBright ( `[roleSelectMenu] Loaded ${ ( chalk . yellow ( roleSelectMenuFiles [ j ] ) ) } with roleSelectMenu ${ ( chalk . yellow ( roleSelectMenu . default . id ) ) } ` ) ) ;
2323 files ++ ;
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ async function loadStringSelectMenus(client) {
1717 for ( let i = 0 ; i < stringSelectMenuFolders . length ; i ++ ) {
1818 const stringSelectMenuFiles = readdirSync ( `./src/interactions/stringSelectMenus/${ stringSelectMenuFolders [ i ] . name } ` ) . filter ( file => file . endsWith ( '.js' ) ) ;
1919 for ( let j = 0 ; j < stringSelectMenuFiles . length ; j ++ ) {
20- const stringSelectMenu = await import ( `../interactions/stringSelectMenus/${ selectMenuFolders [ i ] . name } /${ selectMenuFiles [ j ] } ?${ Date . now ( ) } ` ) ;
20+ const stringSelectMenu = await import ( `../interactions/stringSelectMenus/${ stringSelectMenuFolders [ i ] . name } /${ stringSelectMenuFiles [ j ] } ?${ Date . now ( ) } ` ) ;
2121 await client . stringSelectMenus . set ( stringSelectMenu . default . id , stringSelectMenu . default ) ;
2222 console . log ( chalk . greenBright ( `[STRINGSELECTMENU] Loaded ${ ( chalk . yellow ( stringSelectMenuFiles [ j ] ) ) } with stringSelectMenu ${ ( chalk . yellow ( stringSelectMenu . default . id ) ) } ` ) ) ;
2323 files ++ ;
Original file line number Diff line number Diff line change 1+ import { readdirSync } from 'fs' ;
2+ import chalk from 'chalk' ;
3+
4+ async function loadUserSelectMenus ( client ) {
5+ client . userSelectMenus . clear ( ) ;
6+ let files = 0 ;
7+ const userSelectMenuFiles = readdirSync ( './src/interactions/userSelectMenus' ) . filter ( file => file . endsWith ( '.js' ) ) ;
8+ if ( ! client . userSelectMenus ) return ;
9+ for ( let i = 0 ; i < userSelectMenuFiles . length ; i ++ ) {
10+ const userSelectMenu = await import ( `../interactions/userSelectMenus/${ userSelectMenuFiles [ i ] } ?${ Date . now ( ) } ` ) ;
11+ await client . userSelectMenus . set ( userSelectMenu . default . id , userSelectMenu . default ) ;
12+ console . log ( chalk . greenBright ( `[userSelectMenu] Loaded ${ ( chalk . yellow ( userSelectMenuFiles [ i ] ) ) } with userSelectMenu ${ ( chalk . yellow ( userSelectMenu . default . id ) ) } ` ) ) ;
13+ files ++ ;
14+ }
15+ const userSelectMenuFolders = readdirSync ( './src/interactions/userSelectMenus' , { withFileTypes : true } ) . filter ( file => file . isDirectory ( ) ) ;
16+ if ( ! userSelectMenuFolders ) return ;
17+ for ( let i = 0 ; i < userSelectMenuFolders . length ; i ++ ) {
18+ const userSelectMenuFiles = readdirSync ( `./src/interactions/userSelectMenus/${ userSelectMenuFolders [ i ] . name } ` ) . filter ( file => file . endsWith ( '.js' ) ) ;
19+ for ( let j = 0 ; j < userSelectMenuFiles . length ; j ++ ) {
20+ const userSelectMenu = await import ( `../interactions/userSelectMenus/${ userSelectMenuFolders [ i ] . name } /${ userSelectMenuFiles [ j ] } ?${ Date . now ( ) } ` ) ;
21+ await client . userSelectMenus . set ( userSelectMenu . default . id , userSelectMenu . default ) ;
22+ console . log ( chalk . greenBright ( `[userSelectMenu] Loaded ${ ( chalk . yellow ( userSelectMenuFiles [ j ] ) ) } with userSelectMenu ${ ( chalk . yellow ( userSelectMenu . default . id ) ) } ` ) ) ;
23+ files ++ ;
24+ }
25+ }
26+ return files ;
27+ }
28+
29+ export default { loadUserSelectMenus } ;
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import stringSelectMenuHandler from './handlers/stringSelectMenus.js';
1010import channelSelectMenuHandler from './handlers/channelSelectMenus.js' ;
1111import mentionableSelectMenuHandler from './handlers/mentionableSelectMenus.js' ;
1212import roleSelectMenuHandler from './handlers/roleSelectMenus.js' ;
13+ import userSelectMenuHandler from './handlers/userSelectMenus.js' ;
1314import contextMenus from './handlers/contextMenus.js' ;
1415import register from './handlers/register.js' ;
1516
@@ -40,6 +41,7 @@ client.stringSelectMenus = new Discord.Collection();
4041client . channelSelectMenus = new Discord . Collection ( ) ;
4142client . mentionableSelectMenus = new Discord . Collection ( ) ;
4243client . roleSelectMenus = new Discord . Collection ( ) ;
44+ client . userSelectMenus = new Discord . Collection ( ) ;
4345client . contextMenus = new Discord . Collection ( ) ;
4446
4547await eventHandler . loadEvents ( client ) ;
@@ -51,6 +53,7 @@ await stringSelectMenuHandler.loadStringSelectMenus(client);
5153await channelSelectMenuHandler . loadChannelSelectMenus ( client ) ;
5254await mentionableSelectMenuHandler . loadMentionableSelectMenus ( client ) ;
5355await roleSelectMenuHandler . loadRoleSelectMenus ( client ) ;
56+ await userSelectMenuHandler . loadUserSelectMenus ( client ) ;
5457await contextMenus . loadContextMenus ( client ) ;
5558await register . load ( client ) ;
5659
You can’t perform that action at this time.
0 commit comments