mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 02:53:31 +01:00
fix(GuildEmojiManager): check for guild in methods that use it (#4886)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const BaseManager = require('./BaseManager');
|
||||
const { TypeError } = require('../errors');
|
||||
const { Error, TypeError } = require('../errors');
|
||||
const GuildEmoji = require('../structures/GuildEmoji');
|
||||
const ReactionEmoji = require('../structures/ReactionEmoji');
|
||||
const Collection = require('../util/Collection');
|
||||
@@ -16,9 +16,9 @@ class GuildEmojiManager extends BaseManager {
|
||||
super(guild.client, iterable, GuildEmoji);
|
||||
/**
|
||||
* The guild this manager belongs to
|
||||
* @type {Guild}
|
||||
* @type {?Guild}
|
||||
*/
|
||||
this.guild = guild;
|
||||
this.guild = 'name' in guild ? guild : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -28,6 +28,7 @@ class GuildEmojiManager extends BaseManager {
|
||||
*/
|
||||
|
||||
add(data, cache) {
|
||||
if (!this.guild) throw new Error('GUILDEMOJIMANAGER_NO_GUILD');
|
||||
return super.add(data, cache, { extras: [this.guild] });
|
||||
}
|
||||
|
||||
@@ -51,6 +52,7 @@ class GuildEmojiManager extends BaseManager {
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async create(attachment, name, { roles, reason } = {}) {
|
||||
if (!this.guild) throw new Error('GUILDEMOJIMANAGER_NO_GUILD');
|
||||
attachment = await DataResolver.resolveImage(attachment);
|
||||
if (!attachment) throw new TypeError('REQ_RESOURCE_TYPE');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user