From 7f980e38b6838eaa0537d11e4d0848660c784a0c Mon Sep 17 00:00:00 2001 From: Rodry <38259440+ImRodry@users.noreply.github.com> Date: Tue, 7 Dec 2021 19:14:49 +0000 Subject: [PATCH] feat(ApplicationCommand): add setX methods for easier editing (#7063) Co-authored-by: awned <65061212+ceilingfans@users.noreply.github.com> --- src/structures/ApplicationCommand.js | 36 ++++++++++++++++++++++++++++ typings/index.d.ts | 4 ++++ 2 files changed, 40 insertions(+) diff --git a/src/structures/ApplicationCommand.js b/src/structures/ApplicationCommand.js index a3fb51499e12..ea4558efc71c 100644 --- a/src/structures/ApplicationCommand.js +++ b/src/structures/ApplicationCommand.js @@ -170,6 +170,42 @@ class ApplicationCommand extends Base { return this.manager.edit(this, data, this.guildId); } + /** + * Edits the name of this ApplicationCommand + * @param {string} name The new name of the command + * @returns {Promise} + */ + setName(name) { + return this.edit({ name }); + } + + /** + * Edits the description of this ApplicationCommand + * @param {string} description The new description of the command + * @returns {Promise} + */ + setDescription(description) { + return this.edit({ description }); + } + + /** + * Edits the default permission of this ApplicationCommand + * @param {boolean} [defaultPermission=true] The default permission for this command + * @returns {Promise} + */ + setDefaultPermission(defaultPermission = true) { + return this.edit({ defaultPermission }); + } + + /** + * Edits the options of this ApplicationCommand + * @param {ApplicationCommandOptionData[]} options The options to set for this command + * @returns {Promise} + */ + setOptions(options) { + return this.edit({ options }); + } + /** * Deletes this command. * @returns {Promise} diff --git a/typings/index.d.ts b/typings/index.d.ts index d42d925dc24f..4cdc0473afcd 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -226,6 +226,10 @@ export class ApplicationCommand extends Base { public version: Snowflake; public delete(): Promise>; public edit(data: ApplicationCommandData): Promise>; + public setName(name: string): Promise>; + public setDescription(description: string): Promise>; + public setDefaultPermission(defaultPermission?: boolean): Promise>; + public setOptions(options: ApplicationCommandOptionData[]): Promise>; public equals( command: ApplicationCommand | ApplicationCommandData | RawApplicationCommandData, enforceOptionorder?: boolean,