1- import { Client , IntentsBitField , REST , SlashCommandBuilder , Routes , SlashCommandSubcommandBuilder } from "discord.js" ;
1+ import { Client , IntentsBitField , REST , SlashCommandBuilder , Routes , SlashCommandSubcommandBuilder , RESTPostAPIApplicationCommandsJSONBody } from "discord.js" ;
22import fs from 'fs' ;
33import knex , { Knex } from "knex" ;
44import toml from 'toml' ;
@@ -76,7 +76,7 @@ class DBot extends Client {
7676 }
7777
7878 commands = {
79- list : [ ] as any [ ] ,
79+ list : [ ] as RESTPostAPIApplicationCommandsJSONBody [ ] ,
8080
8181 parse : async ( ) => {
8282 const folderPath = join ( __dirname , 'commands' ) ;
@@ -85,38 +85,14 @@ class DBot extends Client {
8585
8686 for ( const category of commandCategories ) {
8787 const commandsPath = join ( folderPath , category ) ;
88- const commandFiles = readdirSync ( commandsPath ) . filter ( file => file . endsWith ( '.js' ) ) ;
88+ const commandFiles = readdirSync ( commandsPath ) ;
8989
9090 for ( const file of commandFiles ) {
9191 const filePath = join ( commandsPath , file ) ;
9292 const commandClass = ( await import ( `file://${ filePath } ` ) ) . default ;
9393 const command : SlashCommand = new commandClass ( this . kogBot ) ;
94- const slashCommand = new SlashCommandBuilder ( ) ;
9594
96- slashCommand . setName ( command . name ) ;
97- slashCommand . setDescription ( command . description ) ;
98-
99- for ( const parameter of command . parameters ) {
100- slashCommand . options . push ( parameter ) ;
101- }
102-
103- if ( command . subcommands . length > 0 ) {
104- for ( const subcommand of command . subcommands ) {
105- const sub = new SlashCommandSubcommandBuilder ( )
106- . setName ( subcommand . name )
107- . setDescription ( subcommand . description ) ;
108- for ( const parameter of command . parameters ) {
109- sub . options . push ( parameter ) ;
110- }
111- slashCommand . addSubcommand ( sub ) ;
112- }
113-
114- }
115-
116- commands . push ( {
117- builder : slashCommand ,
118- instance : command
119- } ) ;
95+ commands . push ( command . data . toJSON ( ) ) ;
12096 }
12197 }
12298 return commands ;
@@ -131,7 +107,7 @@ class DBot extends Client {
131107 console . log ( `Deploying ${ this . commands . list . length } commands...` ) ;
132108 await this . REST . put (
133109 Routes . applicationCommands ( this . kogBot . environment . discord . client_id ) ,
134- { body : this . commands . list . map ( cmd => cmd . builder ) }
110+ { body : [ ] }
135111 ) ;
136112 }
137113 }
0 commit comments