File tree Expand file tree Collapse file tree 4 files changed +40
-22
lines changed
packages/commandkit/src/app Expand file tree Collapse file tree 4 files changed +40
-22
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import { tasks } from '@commandkit/tasks';
9
9
export default defineConfig ( {
10
10
plugins : [
11
11
i18n ( ) ,
12
- legacy ( { skipBuiltInValidations : true } ) ,
12
+ // legacy({ skipBuiltInValidations: true }),
13
13
devtools ( ) ,
14
14
cache ( ) ,
15
15
ai ( ) ,
Original file line number Diff line number Diff line change 1
- import { MessageContextMenuCommand } from 'commandkit' ;
1
+ import {
2
+ ChatInputCommand ,
3
+ MessageCommand ,
4
+ MessageContextMenuCommand ,
5
+ UserContextMenuCommand ,
6
+ } from 'commandkit' ;
2
7
import { ApplicationCommandType , ContextMenuCommandBuilder } from 'discord.js' ;
3
8
4
9
export const command = new ContextMenuCommandBuilder ( )
5
10
. setName ( 'translate' )
6
- . setType ( ApplicationCommandType . Message ) ;
11
+ . setType ( ApplicationCommandType . User ) ;
12
+
13
+ // export const command: CommandData = {
14
+ // name: 'translate',
15
+ // };
16
+
17
+ export const userContextMenu : UserContextMenuCommand = async ( {
18
+ interaction,
19
+ } ) => {
20
+ interaction . reply ( 'test' ) ;
21
+ } ;
7
22
8
23
export const messageContextMenu : MessageContextMenuCommand = async ( {
9
24
interaction,
10
25
} ) => {
11
26
interaction . reply ( 'test' ) ;
12
27
} ;
28
+
29
+ export const chatInput : ChatInputCommand = async ( { interaction } ) => {
30
+ interaction . reply ( 'test' ) ;
31
+ } ;
32
+
33
+ export const message : MessageCommand = async ( { message } ) => {
34
+ message . reply ( 'test' ) ;
35
+ } ;
Original file line number Diff line number Diff line change 1
1
import {
2
+ ApplicationCommandType ,
2
3
AutocompleteInteraction ,
3
4
Awaitable ,
4
5
Collection ,
@@ -783,7 +784,7 @@ export class AppCommandHandler {
783
784
*/
784
785
private async loadCommand ( id : string , command : Command ) {
785
786
try {
786
- // Skip if path is null (directory-only command group)
787
+ // Skip if path is null (directory-only command group) - external plugins
787
788
if ( command . path === null ) {
788
789
this . loadedCommands . set ( id , {
789
790
command,
@@ -796,8 +797,6 @@ export class AppCommandHandler {
796
797
data : {
797
798
command : {
798
799
name : command . name ,
799
- description : `${ command . name } command` ,
800
- type : 1 ,
801
800
} ,
802
801
} ,
803
802
} ) ;
@@ -836,7 +835,7 @@ export class AppCommandHandler {
836
835
| string
837
836
| undefined ;
838
837
839
- // since `description` is optional in `CommandData` type , set a fallback description if none is provided
838
+ // since `CommandData. description` is optional, set a fallback description if none provided
840
839
if ( ! commandDescription && commandFileData . chatInput ) {
841
840
commandDescription = 'No command description set.' ;
842
841
}
Original file line number Diff line number Diff line change @@ -50,41 +50,37 @@ export class CommandRegistrar {
50
50
51
51
const __metadata = cmd . metadata ?? cmd . data . metadata ;
52
52
53
- const collections : ( CommandData & { __metadata ?: CommandMetadata } ) [ ] = [
54
- {
53
+ const collections : ( CommandData & { __metadata ?: CommandMetadata } ) [ ] =
54
+ [ ] ;
55
+
56
+ if ( cmd . data . chatInput ) {
57
+ collections . push ( {
55
58
...json ,
59
+ type : ApplicationCommandType . ChatInput ,
60
+ description : json . description ?? 'No command description set.' ,
56
61
__metadata,
57
- } ,
58
- ] ;
62
+ } ) ;
63
+ }
59
64
60
65
// Handle context menu commands
61
- if (
62
- cmd . data . userContextMenu &&
63
- json . type !== ApplicationCommandType . User
64
- ) {
66
+ if ( cmd . data . userContextMenu ) {
65
67
collections . push ( {
66
68
...json ,
67
69
name : __metadata ?. nameAliases ?. user ?? json . name ,
68
70
type : ApplicationCommandType . User ,
69
71
options : undefined ,
70
72
description_localizations : undefined ,
71
- // @ts -ignore
72
73
description : undefined ,
73
- // @ts -ignore
74
74
__metadata,
75
75
} ) ;
76
76
}
77
77
78
- if (
79
- cmd . data . messageContextMenu &&
80
- json . type !== ApplicationCommandType . Message
81
- ) {
78
+ if ( cmd . data . messageContextMenu ) {
82
79
collections . push ( {
83
80
...json ,
84
81
name : __metadata ?. nameAliases ?. message ?? json . name ,
85
82
type : ApplicationCommandType . Message ,
86
83
description_localizations : undefined ,
87
- // @ts -ignore
88
84
description : undefined ,
89
85
options : undefined ,
90
86
__metadata,
You can’t perform that action at this time.
0 commit comments