@@ -112,6 +112,7 @@ export abstract class Command<T = Args> extends AliasPiece {
112
112
this . parseConstructorPreConditionsRunIn ( options ) ;
113
113
this . parseConstructorPreConditionsNsfw ( options ) ;
114
114
this . parseConstructorPreConditionsRequiredClientPermissions ( options ) ;
115
+ this . parseConstructorPreConditionsRequiredUserPermissions ( options ) ;
115
116
this . parseConstructorPreConditionsCooldown ( options ) ;
116
117
}
117
118
@@ -135,14 +136,26 @@ export abstract class Command<T = Args> extends AliasPiece {
135
136
}
136
137
137
138
/**
138
- * Appends the `Permissions ` precondition when {@link CommandOptions.requiredClientPermissions} resolves to a
139
+ * Appends the `ClientPermissions ` precondition when {@link CommandOptions.requiredClientPermissions} resolves to a
139
140
* non-zero bitfield.
140
141
* @param options The command options given from the constructor.
141
142
*/
142
143
protected parseConstructorPreConditionsRequiredClientPermissions ( options : CommandOptions ) {
143
144
const permissions = new Permissions ( options . requiredClientPermissions ) ;
144
145
if ( permissions . bitfield !== 0n ) {
145
- this . preconditions . append ( { name : CommandPreConditions . Permissions , context : { permissions } } ) ;
146
+ this . preconditions . append ( { name : CommandPreConditions . ClientPermissions , context : { permissions } } ) ;
147
+ }
148
+ }
149
+
150
+ /**
151
+ * Appends the `UserPermissions` precondition when {@link CommandOptions.requiredUserPermissions} resolves to a
152
+ * non-zero bitfield.
153
+ * @param options The command options given from the constructor.
154
+ */
155
+ protected parseConstructorPreConditionsRequiredUserPermissions ( options : CommandOptions ) {
156
+ const permissions = new Permissions ( options . requiredUserPermissions ) ;
157
+ if ( permissions . bitfield !== 0n ) {
158
+ this . preconditions . append ( { name : CommandPreConditions . UserPermissions , context : { permissions } } ) ;
146
159
}
147
160
}
148
161
@@ -269,7 +282,8 @@ export const enum CommandPreConditions {
269
282
GuildTextOnly = 'GuildTextOnly' ,
270
283
GuildThreadOnly = 'GuildThreadOnly' ,
271
284
NotSafeForWork = 'NSFW' ,
272
- Permissions = 'Permissions'
285
+ ClientPermissions = 'ClientPermissions' ,
286
+ UserPermissions = 'UserPermissions'
273
287
}
274
288
275
289
/**
@@ -361,6 +375,13 @@ export interface CommandOptions extends AliasPieceOptions, FlagStrategyOptions {
361
375
*/
362
376
requiredClientPermissions ?: PermissionResolvable ;
363
377
378
+ /**
379
+ * The required permissions for the user.
380
+ * @since 2.0.0
381
+ * @default 0
382
+ */
383
+ requiredUserPermissions ?: PermissionResolvable ;
384
+
364
385
/**
365
386
* The channels the command should run in. If set to `null`, no precondition entry will be added. Some optimizations are applied when given an array to reduce the amount of preconditions run (e.g. `'text'` and `'news'` becomes `'guild'`, and if both `'dm'` and `'guild'` are defined, then no precondition entry is added as it runs in all channels).
366
387
* @since 2.0.0
0 commit comments