mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
feat(Emoji): backport delete method (#3343)
This backports #1877 (c93c4ad21f) in a semver-minor manner.
This commit is contained in:
@@ -754,7 +754,7 @@ class RESTMethods {
|
||||
|
||||
deleteEmoji(emoji, reason) {
|
||||
return this.rest.makeRequest('delete', Endpoints.Guild(emoji.guild).Emoji(emoji.id), true, undefined, reason)
|
||||
.then(() => this.client.actions.GuildEmojiDelete.handle(emoji).data);
|
||||
.then(() => this.client.actions.GuildEmojiDelete.handle(emoji).emoji);
|
||||
}
|
||||
|
||||
getGuildAuditLogs(guild, options = {}) {
|
||||
|
||||
@@ -222,6 +222,16 @@ class Emoji {
|
||||
return this.edit({ roles: newRoles });
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deletes the emoji.
|
||||
* @param {string} [reason] Reason for deleting the emoji
|
||||
* @returns {Promise<Emoji>}
|
||||
*/
|
||||
delete(reason) {
|
||||
return this.client.rest.methods.deleteEmoji(this, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* When concatenated with a string, this automatically returns the emoji mention rather than the object.
|
||||
* @returns {string}
|
||||
|
||||
@@ -1322,11 +1322,12 @@ class Guild {
|
||||
* @param {Emoji|string} emoji The emoji to delete
|
||||
* @param {string} [reason] Reason for deleting the emoji
|
||||
* @returns {Promise}
|
||||
* @deprecated
|
||||
*/
|
||||
deleteEmoji(emoji, reason) {
|
||||
if (typeof emoji === 'string') emoji = this.emojis.get(emoji);
|
||||
if (!(emoji instanceof Emoji)) throw new TypeError('Emoji must be either an instance of Emoji or an ID');
|
||||
return this.client.rest.methods.deleteEmoji(emoji, reason);
|
||||
return emoji.delete(reason);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1595,4 +1596,7 @@ Guild.prototype.search =
|
||||
Guild.prototype.sync =
|
||||
util.deprecate(Guild.prototype.sync, 'Guild#sync:, userbot methods will be removed');
|
||||
|
||||
Guild.prototype.deleteEmoji =
|
||||
util.deprecate(Guild.prototype.deleteEmoji, 'Guild#deleteEmoji: use Emoji#delete instead');
|
||||
|
||||
module.exports = Guild;
|
||||
|
||||
1
typings/index.d.ts
vendored
1
typings/index.d.ts
vendored
@@ -420,6 +420,7 @@ declare module 'discord.js' {
|
||||
public addRestrictedRoles(roles: Role[]): Promise<Emoji>;
|
||||
public edit(data: EmojiEditData, reason?: string): Promise<Emoji>;
|
||||
public equals(other: Emoji | object): boolean;
|
||||
public delete(reason?: string): Promise<this>;
|
||||
public fetchAuthor(): Promise<User>;
|
||||
public removeRestrictedRole(role: Role): Promise<Emoji>;
|
||||
public removeRestrictedRoles(roles: Role[]): Promise<Emoji>;
|
||||
|
||||
Reference in New Issue
Block a user