Skip to content

Commit

Permalink
feat(ApplicationCommand): add setX methods for easier editing (#7063)
Browse files Browse the repository at this point in the history
Co-authored-by: awned <65061212+ceilingfans@users.noreply.github.com>
  • Loading branch information
ImRodry and ceilingfans committed Dec 7, 2021
1 parent b5cd288 commit 7f980e3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/structures/ApplicationCommand.js
Expand Up @@ -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<ApplicationCommand>}
*/
setName(name) {
return this.edit({ name });
}

/**
* Edits the description of this ApplicationCommand
* @param {string} description The new description of the command
* @returns {Promise<ApplicationCommand>}
*/
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<ApplicationCommand>}
*/
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<ApplicationCommand>}
*/
setOptions(options) {
return this.edit({ options });
}

/**
* Deletes this command.
* @returns {Promise<ApplicationCommand>}
Expand Down
4 changes: 4 additions & 0 deletions typings/index.d.ts
Expand Up @@ -226,6 +226,10 @@ export class ApplicationCommand<PermissionsFetchType = {}> extends Base {
public version: Snowflake;
public delete(): Promise<ApplicationCommand<PermissionsFetchType>>;
public edit(data: ApplicationCommandData): Promise<ApplicationCommand<PermissionsFetchType>>;
public setName(name: string): Promise<ApplicationCommand<PermissionsFetchType>>;
public setDescription(description: string): Promise<ApplicationCommand<PermissionsFetchType>>;
public setDefaultPermission(defaultPermission?: boolean): Promise<ApplicationCommand<PermissionsFetchType>>;
public setOptions(options: ApplicationCommandOptionData[]): Promise<ApplicationCommand<PermissionsFetchType>>;
public equals(
command: ApplicationCommand | ApplicationCommandData | RawApplicationCommandData,
enforceOptionorder?: boolean,
Expand Down

0 comments on commit 7f980e3

Please sign in to comment.