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

refactor(Emoji): remove Guild#deleteEmoji in favour of Emoji#delete #1877

Merged
merged 1 commit into from
Sep 3, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/structures/Emoji.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ class Emoji extends Base {
return this.requiresColons ? `<:${this.name}:${this.id}>` : this.name;
}

/**
* Delete the emoji.
* @param {string} [reason] Reason for deleting the emoji
* @returns {Promise<Emoji>}
*/
delete(reason) {
return this.client.api.guilds(this.guild.id).emojis(this.id).delete({ reason })
.then(() => this);
}

/**
* Whether this emoji is the same as another one.
* @param {Emoji|Object} other The emoji to compare it to
Expand Down
13 changes: 0 additions & 13 deletions src/structures/Guild.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const Long = require('long');
const Role = require('./Role');
const Emoji = require('./Emoji');
const Invite = require('./Invite');
const GuildAuditLogs = require('./GuildAuditLogs');
const Webhook = require('./Webhook');
Expand Down Expand Up @@ -1055,18 +1054,6 @@ class Guild extends Base {
.then(image => this.createEmoji(image, name, { roles, reason }));
}

/**
* Delete an emoji.
* @param {Emoji|string} emoji The emoji to delete
* @param {string} [reason] Reason for deleting the emoji
* @returns {Promise<Emoji>}
*/
deleteEmoji(emoji, reason) {
if (!(emoji instanceof Emoji)) emoji = this.emojis.get(emoji);
return this.client.api.guilds(this.id).emojis(emoji.id).delete({ reason })
.then(() => this.client.actions.GuildEmojiDelete.handle(emoji).data);
}

/**
* Causes the client to leave the guild.
* @returns {Promise<Guild>}
Expand Down