mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 04:53:30 +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:
@@ -252,6 +252,7 @@ class ApplicationCommandManager extends CachedManager {
|
||||
name: command.name,
|
||||
name_localizations: command.nameLocalizations ?? command.name_localizations,
|
||||
description: command.description,
|
||||
nsfw: command.nsfw,
|
||||
description_localizations: command.descriptionLocalizations ?? command.description_localizations,
|
||||
type: command.type,
|
||||
options: command.options?.map(o => ApplicationCommand.transformOption(o)),
|
||||
|
||||
@@ -52,6 +52,12 @@ class ApplicationCommand extends Base {
|
||||
*/
|
||||
this.type = data.type;
|
||||
|
||||
/**
|
||||
* Whether this command is age-restricted (18+)
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.nsfw = data.nsfw ?? false;
|
||||
|
||||
this._patch(data);
|
||||
}
|
||||
|
||||
@@ -188,6 +194,7 @@ class ApplicationCommand extends Base {
|
||||
* {@link ApplicationCommandType.ChatInput}
|
||||
* @property {Object<Locale, string>} [nameLocalizations] The localizations for the command name
|
||||
* @property {string} description The description of the command, if type is {@link ApplicationCommandType.ChatInput}
|
||||
* @property {boolean} [nsfw] Whether the command is age-restricted
|
||||
* @property {Object<Locale, string>} [descriptionLocalizations] The localizations for the command description,
|
||||
* if type is {@link ApplicationCommandType.ChatInput}
|
||||
* @property {ApplicationCommandType} [type=ApplicationCommandType.ChatInput] The type of the command
|
||||
@@ -377,6 +384,7 @@ class ApplicationCommand extends Base {
|
||||
('description' in command && command.description !== this.description) ||
|
||||
('version' in command && command.version !== this.version) ||
|
||||
(command.type && command.type !== this.type) ||
|
||||
('nsfw' in command && command.nsfw !== this.nsfw) ||
|
||||
// Future proof for options being nullable
|
||||
// TODO: remove ?? 0 on each when nullable
|
||||
(command.options?.length ?? 0) !== (this.options?.length ?? 0) ||
|
||||
|
||||
2
packages/discord.js/typings/index.d.ts
vendored
2
packages/discord.js/typings/index.d.ts
vendored
@@ -419,6 +419,7 @@ export class ApplicationCommand<PermissionsFetchType = {}> extends Base {
|
||||
>;
|
||||
public type: ApplicationCommandType;
|
||||
public version: Snowflake;
|
||||
public nsfw: boolean;
|
||||
public delete(): Promise<ApplicationCommand<PermissionsFetchType>>;
|
||||
public edit(data: Partial<ApplicationCommandData>): Promise<ApplicationCommand<PermissionsFetchType>>;
|
||||
public setName(name: string): Promise<ApplicationCommand<PermissionsFetchType>>;
|
||||
@@ -4169,6 +4170,7 @@ export interface BaseApplicationCommandData {
|
||||
nameLocalizations?: LocalizationMap;
|
||||
dmPermission?: boolean;
|
||||
defaultMemberPermissions?: PermissionResolvable | null;
|
||||
nsfw?: boolean;
|
||||
}
|
||||
|
||||
export interface AttachmentData {
|
||||
|
||||
Reference in New Issue
Block a user