Skip to content
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
2 changes: 2 additions & 0 deletions src/errors/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ 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: 5 additions & 3 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 { TypeError } = require('../errors');
const { Error, 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 = guild;
this.guild = 'name' in guild ? guild : null;
}

/**
Expand All @@ -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] });
}

Expand All @@ -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');

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;
public guild: Guild | null;
public create(
attachment: BufferResolvable | Base64Resolvable,
name: string,
Expand Down