@@ -6,6 +6,7 @@ import { Commands } from '../managers/CommandManager';
6
6
import { Locale , LocaleString } from '../util/common' ;
7
7
import { Logger } from '../util/logger/Logger' ;
8
8
import { commandAndOptionNameRegexp } from '../util/regexes' ;
9
+ import type { PermissionResolvable , Permissions } from 'discord.js' ;
9
10
10
11
export enum CommandType {
11
12
/**
@@ -37,6 +38,8 @@ export interface CommandOptions {
37
38
description ?: string ;
38
39
descriptionLocalizations ?: Record < LocaleString , string > ;
39
40
type : Array < CommandType | keyof typeof CommandType > ;
41
+ defaultMemberPermissions ?: PermissionResolvable ;
42
+ dmPermission ?: boolean ;
40
43
arguments ?: Array < Argument | ArgumentOptions > ;
41
44
inhibitors ?: CommandInhibitors ;
42
45
guildId ?: string ;
@@ -84,6 +87,8 @@ const validationSchema = z
84
87
)
85
88
. array ( )
86
89
. nonempty ( ) ,
90
+ defaultMemberPermissions : z . any ( ) . optional ( ) ,
91
+ dmPermission : z . boolean ( ) . optional ( ) ,
87
92
arguments : z . any ( ) . array ( ) . optional ( ) ,
88
93
inhibitors : z . any ( ) . array ( ) . optional ( ) ,
89
94
guildId : z . string ( ) . optional ( ) ,
@@ -109,6 +114,8 @@ export class Command {
109
114
public description ?: string ;
110
115
public descriptionLocalizations ?: Record < LocaleString , string > ;
111
116
public type : Array < CommandType | keyof typeof CommandType > ;
117
+ public defaultMemberPermissions ?: PermissionResolvable ;
118
+ public dmPermission ?: boolean ;
112
119
public arguments ?: Array < Argument > ;
113
120
public inhibitors : CommandInhibitors ;
114
121
public guildId ?: string ;
@@ -136,6 +143,11 @@ export class Command {
136
143
options . descriptionLocalizations ||
137
144
Command . defaults ?. descriptionLocalizations ;
138
145
this . type = options . type || Command . defaults ?. type ;
146
+ this . defaultMemberPermissions =
147
+ options . defaultMemberPermissions ||
148
+ Command . defaults ?. defaultMemberPermissions ;
149
+ this . dmPermission =
150
+ options . dmPermission || Command . defaults ?. dmPermission ;
139
151
this . arguments = options . arguments ?. map ( argument => {
140
152
if ( argument instanceof Argument ) return argument ;
141
153
else return new Argument ( argument ) ;
@@ -218,6 +230,8 @@ export class Command {
218
230
name_localizations : this . nameLocalizations ,
219
231
description : this . description ,
220
232
description_localizations : this . descriptionLocalizations ,
233
+ dm_permission : this . dmPermission ,
234
+ default_member_permissions : this . defaultMemberPermissions ,
221
235
options : this . arguments ?. map ( argument => argument . toJSON ( ) ) ,
222
236
type : type ,
223
237
} ;
0 commit comments