Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ApplicationCommand): add setX methods for easier editing #7063

Merged
merged 2 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/structures/ApplicationCommand.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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>>;
ImRodry marked this conversation as resolved.
Show resolved Hide resolved
public equals(
command: ApplicationCommand | ApplicationCommandData | RawApplicationCommandData,
enforceOptionorder?: boolean,
Expand Down