Skip to content

Commit

Permalink
feat(Command): add nsfw commands support (#481)
Browse files Browse the repository at this point in the history
**Please describe the changes this PR makes and why it should be
merged:**
waiting for official release - X
djs - discordjs/discord.js#7976

**Status and versioning classification:**
- This PR changes the library's interface (methods or parameters added)

<!--
Please move lines that apply to you out of the comment:
- This PR includes breaking changes (methods removed or renamed,
parameters moved or removed)
- This PR **only** includes non-code changes, like changes to
documentation, README, etc.
-->
  • Loading branch information
xHyroM committed Dec 18, 2022
2 parents 3f81e45 + 9c0fa7c commit bd8282c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/structures/Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface CommandOptions {
type: Array<CommandType | keyof typeof CommandType>;
defaultMemberPermissions?: PermissionResolvable;
dmPermission?: boolean;
nsfw?: boolean;
arguments?: Array<Argument | ArgumentOptions>;
inhibitors?: CommandInhibitors;
guildId?: string;
Expand Down Expand Up @@ -89,6 +90,7 @@ const validationSchema = z
.nonempty(),
defaultMemberPermissions: z.any().optional(),
dmPermission: z.boolean().optional(),
nsfw: z.boolean().optional(),
arguments: z.any().array().optional(),
inhibitors: z.any().array().optional().default([]),
guildId: z.string().optional(),
Expand Down Expand Up @@ -116,6 +118,7 @@ export class Command {
public type: Array<CommandType | keyof typeof CommandType>;
public defaultMemberPermissions?: PermissionResolvable;
public dmPermission?: boolean;
public nsfw?: boolean;
public arguments?: Array<Argument>;
public inhibitors: CommandInhibitors;
public options: Partial<CommandOptions>;
Expand Down Expand Up @@ -149,6 +152,7 @@ export class Command {
Command.defaults?.defaultMemberPermissions;
this.dmPermission =
options.dmPermission ?? Command.defaults?.dmPermission;
this.nsfw = options.nsfw ?? Command.defaults?.nsfw;
this.arguments = options.arguments?.map(argument => {
if (argument instanceof Argument) return argument;
else return new Argument(argument);
Expand Down Expand Up @@ -219,6 +223,7 @@ export class Command {
description: this.description,
description_localizations: this.descriptionLocalizations,
dm_permission: this.dmPermission,
nsfw: this.nsfw,
default_member_permissions: this.defaultMemberPermissions
? new PermissionsBitField(
this.defaultMemberPermissions,
Expand Down

0 comments on commit bd8282c

Please sign in to comment.