File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- export { default as close } from "./util/close.js" ;
2- export { default as reopen } from "./util/reopen.js" ;
1+ import type {
2+ SlashCommandBuilder ,
3+ ChatInputCommandInteraction ,
34
4- export { default as walkthrough } from "./util/walkthrough.js" ;
5+ ContextMenuCommandBuilder ,
6+ ContextMenuCommandInteraction ,
7+ SlashCommandOptionsOnlyBuilder ,
8+ } from "discord.js" ;
9+
10+ import { default as close } from "./util/close.js" ;
11+ import { default as reopen } from "./util/reopen.js" ;
12+ import { default as walkthrough } from "./util/walkthrough.js" ;
13+
14+ type AnyCommandBuilder = SlashCommandBuilder | SlashCommandOptionsOnlyBuilder | ContextMenuCommandBuilder ;
15+ type AnyInteraction = ChatInputCommandInteraction | ContextMenuCommandInteraction ;
16+
17+ const commandObject : { [ key : string ] : { data : AnyCommandBuilder , execute : ( interaction : AnyInteraction ) => unknown } } = { } ;
18+
19+ for ( const command of [ close , reopen , walkthrough ] ) {
20+ commandObject [ command . data . name ] = command ;
21+ }
22+
23+ export default commandObject ;
Original file line number Diff line number Diff line change 11import { config } from "@lib/config.js" ;
2- import * as commands from "@commands/index.js" ;
2+ import { getClientIDFromToken } from "@lib/discord/users.js" ;
3+
4+ import commands from "@commands/index.js" ;
35
46import { REST , Routes } from "discord.js" ;
57
68// Construct and prepare an instance of the REST module
79const rest = new REST ( ) . setToken ( config . token ) ;
810
9- const commandData = Object . values ( commands ) . map ( ( command ) => command . data ) ;
11+ const commandData = Object . values ( commands ) . map ( ( command ) => command . data . toJSON ( ) ) ;
1012
1113console . log (
1214 `Started refreshing ${ commandData . length } application (/) commands.` ,
@@ -15,7 +17,7 @@ console.log(
1517// The put method is used to fully refresh all commands in the guild with the current set
1618// biome-ignore lint/suspicious/noExplicitAny: TODO: need to figure out the proper type
1719const data : any = await rest . put (
18- Routes . applicationGuildCommands ( "1063886601165471814" , config . serverId ) , // TODO: guess client ID from token
20+ Routes . applicationGuildCommands ( getClientIDFromToken ( config . token ) , config . serverId ) , // TODO: guess client ID from token
1921 { body : commandData } ,
2022) ;
2123
Original file line number Diff line number Diff line change 1- import * as commands from "@commands/index.js" ;
1+ import commands from "@commands/index.js" ;
22
33import { type Client , Events } from "discord.js" ;
44
@@ -9,7 +9,7 @@ export default function registerEvents(client: Client) {
99
1010 if ( ! command ) {
1111 console . error (
12- `No command matching ${ interaction . commandName } was found.` ,
12+ `No command matching " ${ interaction . commandName } " was found.` ,
1313 ) ;
1414 return ;
1515 }
@@ -32,6 +32,8 @@ export default function registerEvents(client: Client) {
3232 } ) ;
3333 }
3434 }
35+ } else if ( interaction . isUserContextMenuCommand ( ) ) {
36+
3537 }
3638 } ) ;
3739}
You can’t perform that action at this time.
0 commit comments