File tree Expand file tree Collapse file tree 26 files changed +145
-112
lines changed Expand file tree Collapse file tree 26 files changed +145
-112
lines changed Original file line number Diff line number Diff line change 11import config from '../data/config.js' ;
22import chalk from 'chalk' ;
3- import { REST , Routes } from 'discord.js' ;
3+ import { Client , REST , Routes } from 'discord.js' ;
4+
45const rest = new REST ( { version : '10' } ) . setToken ( config . bot . token ) ;
56
6- async function registerApplicationCommands ( client ) {
7+ async function registerApplicationCommands ( client : Client ) {
78 try {
8- let commands = new Map ( ) ;
9+ if ( ! client . user ) throw new Error ( 'User not available in the client.' ) ;
10+
11+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12+ const commands = new Map < string , any > ( ) ;
913 for ( const [ key , value ] of client . interaction ) {
10- if ( key . startsWith ( 'slashCommand-' ) || key . startsWith ( 'contextMenu-' ) ) commands . set ( key , value ) ;
14+ if ( typeof key === 'string' && ( key . startsWith ( 'slashCommand-' ) || key . startsWith ( 'contextMenu-' ) ) ) {
15+ commands . set ( key , value ) ;
16+ }
1117 }
12-
18+
1319 await rest . put (
1420 Routes . applicationCommands ( client . user . id ) ,
1521 { body : [ ...commands . values ( ) ] . map ( command => command . data . toJSON ( ) ) } ,
1622 ) ;
23+
1724 console . log ( chalk . greenBright ( '[APPLICATION] Successfully registered application commands.' ) ) ;
1825 } catch ( err ) {
1926 console . error ( err ) ;
Original file line number Diff line number Diff line change 11import fs from 'fs' ;
22import chalk from 'chalk' ;
3+ import { Client } from 'discord.js' ;
34
4- async function loadInteractions ( folderPath , client ) {
5+ async function loadInteractions ( folderPath : string , client : Client ) {
56 try {
6- let files = fs . readdirSync ( folderPath ) ;
7+ const files = fs . readdirSync ( folderPath ) ;
78
89 for ( let i = 0 ; i < files . length ; i ++ ) {
9- let file = files [ i ] ;
10- let filePath = folderPath + '/' + file ;
11- let stats = fs . statSync ( filePath ) ;
10+ const file = files [ i ] ;
11+ const filePath = folderPath + '/' + file ;
12+ const stats = fs . statSync ( filePath ) ;
1213
1314 if ( stats . isDirectory ( ) ) {
1415 await loadInteractions ( filePath , client ) ;
1516 } else {
16- let interactionPath = '.' + filePath ;
17- let interaction = await import ( `../${ interactionPath } ?${ Date . now ( ) } ` ) ;
17+ const interactionPath = '.' + filePath ;
18+ const interaction = await import ( `../${ interactionPath } ?${ Date . now ( ) } ` ) ;
1819
1920 if ( interaction . default . disabled === true ) return ;
2021 if ( interaction . default . type === 'messageCommand' ) {
Original file line number Diff line number Diff line change @@ -2,8 +2,8 @@ import Discord from 'discord.js';
22import config from './data/config.js' ;
33
44import loadEvents from './handlers/events.js' ;
5- // import loadInteractions from './handlers/handler.js';
6- // import registerApplicationCommands from './handlers/application.js';
5+ import loadInteractions from './handlers/handler.js' ;
6+ import registerApplicationCommands from './handlers/application.js' ;
77import { loadCronJobs } from './handlers/cronjobs.js' ;
88
99const client = new Discord . Client ( {
@@ -27,9 +27,9 @@ await client.login(config.bot.token);
2727client . interaction = new Discord . Collection ( ) ;
2828
2929await loadEvents ( client ) ;
30- // await loadInteractions('./src /interactions', client);
31- // await registerApplicationCommands(client);
32- await loadCronJobs ( './src /cron' , client ) ;
30+ await loadInteractions ( './dist /interactions' , client ) ;
31+ await registerApplicationCommands ( client ) ;
32+ await loadCronJobs ( './dist /cron' , client ) ;
3333
3434process . on ( 'uncaughtException' , function ( err ) {
3535 console . error ( err ) ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import { Client , ButtonInteraction } from 'discord.js' ;
2+
3+ export default {
4+ id : 'button' ,
5+ type : 'button' ,
6+ disabled : false ,
7+ async execute ( client : Client , interaction : ButtonInteraction ) {
8+ interaction . reply ( 'Hello World!' ) ;
9+ }
10+ } ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import { Client , ChannelSelectMenuInteraction } from 'discord.js' ;
2+
3+ export default {
4+ id : 'channelSelectMenu' ,
5+ type : 'channelSelectMenu' ,
6+ disabled : false ,
7+ async execute ( client : Client , interaction : ChannelSelectMenuInteraction ) {
8+ interaction . reply ( 'Hello World!' ) ;
9+ }
10+ } ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import { Client , MentionableSelectMenuInteraction } from 'discord.js' ;
2+
3+ export default {
4+ id : 'mentionableSelectMenu' ,
5+ type : 'mentionableSelectMenu' ,
6+ disabled : false ,
7+ async execute ( client : Client , interaction : MentionableSelectMenuInteraction ) {
8+ interaction . reply ( 'Hello World!' ) ;
9+ }
10+ } ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments