mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-20 21:43:33 +01:00
fix(GuildEmojiManager): throw an error if image resolving fails (#3934)
* fix(GuildEmojiManager): throw an error if image resolving fails * refactor(GuildEmojiManager): remove redundant if branch
This commit is contained in:
@@ -50,8 +50,10 @@ class GuildEmojiManager extends BaseManager {
|
||||
* .then(emoji => console.log(`Created new emoji with name ${emoji.name}!`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
create(attachment, name, { roles, reason } = {}) {
|
||||
if (typeof attachment === 'string' && attachment.startsWith('data:')) {
|
||||
async create(attachment, name, { roles, reason } = {}) {
|
||||
attachment = await DataResolver.resolveImage(attachment);
|
||||
if (!attachment) throw new TypeError('REQ_RESOURCE_TYPE');
|
||||
|
||||
const data = { image: attachment, name };
|
||||
if (roles) {
|
||||
data.roles = [];
|
||||
@@ -72,9 +74,6 @@ class GuildEmojiManager extends BaseManager {
|
||||
.then(emoji => this.client.actions.GuildEmojiCreate.handle(this.guild, emoji).emoji);
|
||||
}
|
||||
|
||||
return DataResolver.resolveImage(attachment).then(image => this.create(image, name, { roles, reason }));
|
||||
}
|
||||
|
||||
/**
|
||||
* Data that can be resolved into an GuildEmoji object. This can be:
|
||||
* * A custom emoji ID
|
||||
|
||||
Reference in New Issue
Block a user