Skip to content

Commit

Permalink
revert: "fix(GuildEmojiManager): check for guild in methods that use …
Browse files Browse the repository at this point in the history
…it" (discordjs#4912)

This reverts commit 728b3f9.
  • Loading branch information
iCrawl authored and GiorgioBrux committed Oct 17, 2020
1 parent 5e9b3dd commit 9cf10fd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 0 additions & 2 deletions src/errors/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ const Messages = {
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.',

GUILDEMOJIMANAGER_NO_GUILD: 'Method cannot be called from a Client instance.',
};

for (const [name, message] of Object.entries(Messages)) register(name, message);
8 changes: 3 additions & 5 deletions src/managers/GuildEmojiManager.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const BaseManager = require('./BaseManager');
const { Error, TypeError } = require('../errors');
const { TypeError } = require('../errors');
const GuildEmoji = require('../structures/GuildEmoji');
const ReactionEmoji = require('../structures/ReactionEmoji');
const Collection = require('../util/Collection');
Expand All @@ -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 = 'name' in guild ? guild : null;
this.guild = guild;
}

/**
Expand All @@ -28,7 +28,6 @@ class GuildEmojiManager extends BaseManager {
*/

add(data, cache) {
if (!this.guild) throw new Error('GUILDEMOJIMANAGER_NO_GUILD');
return super.add(data, cache, { extras: [this.guild] });
}

Expand All @@ -52,7 +51,6 @@ 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');

Expand Down
2 changes: 1 addition & 1 deletion typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1917,7 +1917,7 @@ declare module 'discord.js' {

export class GuildEmojiManager extends BaseManager<Snowflake, GuildEmoji, EmojiResolvable> {
constructor(guild: Guild, iterable?: Iterable<any>);
public guild: Guild | null;
public guild: Guild;
public create(
attachment: BufferResolvable | Base64Resolvable,
name: string,
Expand Down

0 comments on commit 9cf10fd

Please sign in to comment.