@@ -3,116 +3,29 @@ export default {
33 async execute ( client , interaction ) {
44 try {
55
6- if ( interaction . isUserContextMenuCommand ( ) === true ) {
7- const contextMenu = client . contextMenus . get ( interaction . commandName ) ;
8- if ( ! contextMenu ) return ;
9- try {
10- contextMenu . execute ( client , interaction ) ;
11- } catch ( error ) {
12- interaction . reply ( { content : 'There was an error while executing this context menu!' , ephemeral : true } ) ;
13- console . log ( error ) ;
14- }
6+ const interactionType = ( ( ) => {
7+ if ( interaction . isContextMenuCommand ( ) ) return 'contextMenu' ;
8+ if ( interaction . isMessageContextMenuCommand ( ) ) return 'messageContextMenu' ;
9+ if ( interaction . isUserContextMenuCommand ( ) ) return 'userContextMenu' ;
10+ if ( interaction . isCommand ( ) ) return 'slashCommand' ;
11+ if ( interaction . isModalSubmit ( ) ) return 'modal' ;
12+ if ( interaction . isButton ( ) ) return 'button' ;
13+ if ( interaction . isStringSelectMenu ( ) ) return 'stringSelectMenu' ;
14+ if ( interaction . isChannelSelectMenu ( ) ) return 'channelSelectMenu' ;
15+ if ( interaction . isMentionableSelectMenu ( ) ) return 'mentionableSelectMenu' ;
16+ if ( interaction . isRoleSelectMenu ( ) ) return 'roleSelectMenu' ;
17+ if ( interaction . isUserSelectMenu ( ) ) return 'userSelectMenu' ;
18+ } ) ( ) ;
19+
20+ let action = client . interaction . get ( `${ interactionType } -${ interaction . customId || interaction . commandName } ` ) ;
21+ if ( ! action ) return ;
22+ try {
23+ action . execute ( client , interaction ) ;
24+ } catch ( error ) {
25+ interaction . reply ( { content : 'There was an error while executing this context menu!' , ephemeral : true } ) ;
26+ console . log ( error ) ;
1527 }
1628
17- if ( interaction . isCommand ( ) ) {
18- const command = client . slashCommands . get ( interaction . commandName ) ;
19- if ( ! command ) return ;
20- try {
21- command . execute ( client , interaction ) ;
22- } catch ( error ) {
23- interaction . reply ( { content : 'There was an error while executing this command!' , ephemeral : true } ) ;
24- console . log ( error ) ;
25- }
26- }
27-
28- if ( interaction . isModalSubmit ( ) ) {
29- const modal = client . modals . get ( interaction . customId ) ;
30- if ( ! modal ) return ;
31- try {
32- modal . execute ( client , interaction ) ;
33- } catch ( error ) {
34- interaction . reply ( { content : 'There was an error while executing this modal!' , ephemeral : true } ) ;
35- console . log ( error ) ;
36- }
37- }
38-
39- if ( interaction . isButton ( ) ) {
40- const button = client . buttons . get ( interaction . customId ) ;
41- if ( ! button ) return ;
42- try {
43- button . execute ( client , interaction ) ;
44- } catch ( error ) {
45- interaction . reply ( { content : 'There was an error while executing this button!' , ephemeral : true } ) ;
46- console . log ( error ) ;
47- }
48- }
49-
50- if ( interaction . isAnySelectMenu ( ) ) {
51- const selectMenu = client . selectMenus . get ( interaction . customId ) ;
52- if ( ! selectMenu ) return ;
53- try {
54- selectMenu . execute ( client , interaction ) ;
55- } catch ( error ) {
56- interaction . reply ( { content : 'There was an error while executing this select menu!' , ephemeral : true } ) ;
57- console . log ( error ) ;
58- }
59- }
60-
61- if ( interaction . isStringSelectMenu ( ) ) {
62- const stringSelectMenu = client . stringSelectMenus . get ( interaction . customId ) ;
63- if ( ! stringSelectMenu ) return ;
64- try {
65- stringSelectMenu . execute ( client , interaction ) ;
66- } catch ( error ) {
67- interaction . reply ( { content : 'There was an error while executing this select menu!' , ephemeral : true } ) ;
68- console . log ( error ) ;
69- }
70- }
71-
72- if ( interaction . isChannelSelectMenu ( ) ) {
73- const channelSelectMenu = client . channelSelectMenus . get ( interaction . customId ) ;
74- if ( ! channelSelectMenu ) return ;
75- try {
76- channelSelectMenu . execute ( client , interaction ) ;
77- } catch ( error ) {
78- interaction . reply ( { content : 'There was an error while executing this select menu!' , ephemeral : true } ) ;
79- console . log ( error ) ;
80- }
81- }
82-
83- if ( interaction . isMentionableSelectMenu ( ) ) {
84- const mentionableSelectMenu = client . mentionableSelectMenus . get ( interaction . customId ) ;
85- if ( ! mentionableSelectMenu ) return ;
86- try {
87- mentionableSelectMenu . execute ( client , interaction ) ;
88- } catch ( error ) {
89- interaction . reply ( { content : 'There was an error while executing this select menu!' , ephemeral : true } ) ;
90- console . log ( error ) ;
91- }
92- }
93-
94- if ( interaction . isRoleSelectMenu ( ) ) {
95- const roleSelectMenu = client . roleSelectMenus . get ( interaction . customId ) ;
96- if ( ! roleSelectMenu ) return ;
97- try {
98- roleSelectMenu . execute ( client , interaction ) ;
99- } catch ( error ) {
100- interaction . reply ( { content : 'There was an error while executing this select menu!' , ephemeral : true } ) ;
101- console . log ( error ) ;
102- }
103- }
104-
105- if ( interaction . isUserSelectMenu ( ) ) {
106- const userSelectMenu = client . userSelectMenus . get ( interaction . customId ) ;
107- if ( ! userSelectMenu ) return ;
108- try {
109- userSelectMenu . execute ( client , interaction ) ;
110- } catch ( error ) {
111- interaction . reply ( { content : 'There was an error while executing this select menu!' , ephemeral : true } ) ;
112- console . log ( error ) ;
113- }
114- }
115-
11629 } catch ( error ) {
11730 return console . log ( error ) ;
11831 }
0 commit comments