File tree Expand file tree Collapse file tree 3 files changed +31
-8
lines changed Expand file tree Collapse file tree 3 files changed +31
-8
lines changed 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 ,
3
4
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 1
1
import { 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" ;
3
5
4
6
import { REST , Routes } from "discord.js" ;
5
7
6
8
// Construct and prepare an instance of the REST module
7
9
const rest = new REST ( ) . setToken ( config . token ) ;
8
10
9
- const commandData = Object . values ( commands ) . map ( ( command ) => command . data ) ;
11
+ const commandData = Object . values ( commands ) . map ( ( command ) => command . data . toJSON ( ) ) ;
10
12
11
13
console . log (
12
14
`Started refreshing ${ commandData . length } application (/) commands.` ,
@@ -15,7 +17,7 @@ console.log(
15
17
// The put method is used to fully refresh all commands in the guild with the current set
16
18
// biome-ignore lint/suspicious/noExplicitAny: TODO: need to figure out the proper type
17
19
const 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
19
21
{ body : commandData } ,
20
22
) ;
21
23
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" ;
2
2
3
3
import { type Client , Events } from "discord.js" ;
4
4
@@ -9,7 +9,7 @@ export default function registerEvents(client: Client) {
9
9
10
10
if ( ! command ) {
11
11
console . error (
12
- `No command matching ${ interaction . commandName } was found.` ,
12
+ `No command matching " ${ interaction . commandName } " was found.` ,
13
13
) ;
14
14
return ;
15
15
}
@@ -32,6 +32,8 @@ export default function registerEvents(client: Client) {
32
32
} ) ;
33
33
}
34
34
}
35
+ } else if ( interaction . isUserContextMenuCommand ( ) ) {
36
+
35
37
}
36
38
} ) ;
37
39
}
You can’t perform that action at this time.
0 commit comments