mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 12:03:31 +01:00
feat: add support for nsfw commands (#7976)
* chore: update * fix: add edit changes * chore: make requested changes Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -94,3 +94,7 @@ const memberPermissionPredicate = s.union(
|
||||
export function validateDefaultMemberPermissions(permissions: unknown) {
|
||||
return memberPermissionPredicate.parse(permissions);
|
||||
}
|
||||
|
||||
export function validateNSFW(value: unknown): asserts value is boolean {
|
||||
booleanPredicate.parse(value);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
validateDMPermission,
|
||||
validateMaxOptionsLength,
|
||||
validateRequiredParameters,
|
||||
validateNSFW,
|
||||
} from './Assertions.js';
|
||||
import { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from './SlashCommandSubcommands.js';
|
||||
import { SharedNameAndDescription } from './mixins/NameAndDescription.js';
|
||||
@@ -64,6 +65,11 @@ export class SlashCommandBuilder {
|
||||
*/
|
||||
public readonly dm_permission: boolean | undefined = undefined;
|
||||
|
||||
/**
|
||||
* Whether this command is NSFW
|
||||
*/
|
||||
public readonly nsfw: boolean | undefined = undefined;
|
||||
|
||||
/**
|
||||
* Returns the final data that should be sent to Discord.
|
||||
*
|
||||
@@ -134,6 +140,18 @@ export class SlashCommandBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether this command is NSFW
|
||||
*
|
||||
* @param nsfw - Whether this command is NSFW
|
||||
*/
|
||||
public setNSFW(nsfw = true) {
|
||||
// Assert the value matches the conditions
|
||||
validateNSFW(nsfw);
|
||||
Reflect.set(this, 'nsfw', nsfw);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new subcommand group to this command
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user