revert: "fix(GuildEmojiManager): check for guild in methods that use it" (#4912)

This reverts commit 728b3f939c.
This commit is contained in:
Noel
2020-10-17 15:46:10 +02:00
committed by GitHub
parent 728b3f939c
commit 89feedad98
3 changed files with 4 additions and 8 deletions

View File

@@ -103,8 +103,6 @@ const Messages = {
FETCH_GROUP_DM_CHANNEL: "Bots don't have access to Group DM Channels and cannot fetch them", FETCH_GROUP_DM_CHANNEL: "Bots don't have access to Group DM Channels and cannot fetch them",
MEMBER_FETCH_NONCE_LENGTH: 'Nonce length must not exceed 32 characters.', MEMBER_FETCH_NONCE_LENGTH: 'Nonce length must not exceed 32 characters.',
GUILDEMOJIMANAGER_NO_GUILD: 'Method cannot be called from a Client instance.',
}; };
for (const [name, message] of Object.entries(Messages)) register(name, message); for (const [name, message] of Object.entries(Messages)) register(name, message);

View File

@@ -1,7 +1,7 @@
'use strict'; 'use strict';
const BaseManager = require('./BaseManager'); const BaseManager = require('./BaseManager');
const { Error, TypeError } = require('../errors'); const { TypeError } = require('../errors');
const GuildEmoji = require('../structures/GuildEmoji'); const GuildEmoji = require('../structures/GuildEmoji');
const ReactionEmoji = require('../structures/ReactionEmoji'); const ReactionEmoji = require('../structures/ReactionEmoji');
const Collection = require('../util/Collection'); const Collection = require('../util/Collection');
@@ -16,9 +16,9 @@ class GuildEmojiManager extends BaseManager {
super(guild.client, iterable, GuildEmoji); super(guild.client, iterable, GuildEmoji);
/** /**
* The guild this manager belongs to * The guild this manager belongs to
* @type {?Guild} * @type {Guild}
*/ */
this.guild = 'name' in guild ? guild : null; this.guild = guild;
} }
/** /**
@@ -28,7 +28,6 @@ class GuildEmojiManager extends BaseManager {
*/ */
add(data, cache) { add(data, cache) {
if (!this.guild) throw new Error('GUILDEMOJIMANAGER_NO_GUILD');
return super.add(data, cache, { extras: [this.guild] }); return super.add(data, cache, { extras: [this.guild] });
} }
@@ -52,7 +51,6 @@ class GuildEmojiManager extends BaseManager {
* .catch(console.error); * .catch(console.error);
*/ */
async create(attachment, name, { roles, reason } = {}) { async create(attachment, name, { roles, reason } = {}) {
if (!this.guild) throw new Error('GUILDEMOJIMANAGER_NO_GUILD');
attachment = await DataResolver.resolveImage(attachment); attachment = await DataResolver.resolveImage(attachment);
if (!attachment) throw new TypeError('REQ_RESOURCE_TYPE'); if (!attachment) throw new TypeError('REQ_RESOURCE_TYPE');

2
typings/index.d.ts vendored
View File

@@ -1917,7 +1917,7 @@ declare module 'discord.js' {
export class GuildEmojiManager extends BaseManager<Snowflake, GuildEmoji, EmojiResolvable> { export class GuildEmojiManager extends BaseManager<Snowflake, GuildEmoji, EmojiResolvable> {
constructor(guild: Guild, iterable?: Iterable<any>); constructor(guild: Guild, iterable?: Iterable<any>);
public guild: Guild | null; public guild: Guild;
public create( public create(
attachment: BufferResolvable | Base64Resolvable, attachment: BufferResolvable | Base64Resolvable,
name: string, name: string,