diff --git a/src/index.js b/src/index.js index 217bb149..d4f05a60 100644 --- a/src/index.js +++ b/src/index.js @@ -47,8 +47,6 @@ module.exports = { MessageMentions: require('./structures/MessageMentions'), MessageReaction: require('./structures/MessageReaction'), ClientApplication: require('./structures/ClientApplication'), - PartialGuild: require('./structures/PartialGuild'), - PartialGuildChannel: require('./structures/PartialGuildChannel'), PermissionOverwrites: require('./structures/PermissionOverwrites'), Presence: require('./structures/Presence').Presence, ReactionEmoji: require('./structures/ReactionEmoji'), diff --git a/src/structures/Guild.js b/src/structures/Guild.js index f3e2e625..e562cd46 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -80,7 +80,7 @@ class Guild { * @param {*} data The raw data of the guild * @private */ - setup(data) { + setup(data) { // eslint-disable-line complexity /** * The name of the guild * @type {string} @@ -225,7 +225,7 @@ class Guild { * @type {Collection} */ this.emojis = new Collection(); - for (const emoji of data.emojis) this.emojis.set(emoji.id, new Emoji(this, emoji)); + if (data.emojis) for (const emoji of data.emojis) this.emojis.set(emoji.id, new Emoji(this, emoji)); } else { this.client.actions.GuildEmojisUpdate.handle({ guild_id: this.id, diff --git a/src/structures/Invite.js b/src/structures/Invite.js index 53a94f08..fec7d8bf 100644 --- a/src/structures/Invite.js +++ b/src/structures/Invite.js @@ -1,5 +1,3 @@ -const PartialGuild = require('./PartialGuild'); -const PartialGuildChannel = require('./PartialGuildChannel'); const Constants = require('../util/Constants'); /** @@ -20,12 +18,14 @@ class Invite { } setup(data) { + const Guild = require('./Guild'); + const Channel = require('./Channel'); + /** - * The guild the invite is for. If this guild is already known, this will be a guild object. If the guild is - * unknown, this will be a PartialGuild object - * @type {Guild|PartialGuild} + * The guild the invite is for + * @type {Guild} */ - this.guild = this.client.guilds.get(data.guild.id) || new PartialGuild(this.client, data.guild); + this.guild = this.client.guilds.get(data.guild.id) || new Guild(this.client, data.guild); /** * The code for this invite @@ -90,11 +90,10 @@ class Invite { } /** - * The channel the invite is for. If this channel is already known, this will be a GuildChannel object. - * If the channel is unknown, this will be a PartialGuildChannel object. - * @type {GuildChannel|PartialGuildChannel} + * The channel the invite is for + * @type {GuildChannel} */ - this.channel = this.client.channels.get(data.channel.id) || new PartialGuildChannel(this.client, data.channel); + this.channel = this.client.channels.get(data.channel.id) || Channel.create(this.client, data.channel, this.guild); /** * The timestamp the invite was created at diff --git a/src/structures/PartialGuild.js b/src/structures/PartialGuild.js deleted file mode 100644 index 3eb64f26..00000000 --- a/src/structures/PartialGuild.js +++ /dev/null @@ -1,51 +0,0 @@ -/* -{ splash: null, - id: '123123123', - icon: '123123123', - name: 'name' } -*/ - -/** - * Represents a guild that the client only has limited information for - e.g. from invites. - */ -class PartialGuild { - constructor(client, data) { - /** - * The client that instantiated this PartialGuild - * @name PartialGuild#client - * @type {Client} - * @readonly - */ - Object.defineProperty(this, 'client', { value: client }); - - this.setup(data); - } - - setup(data) { - /** - * The ID of this guild - * @type {Snowflake} - */ - this.id = data.id; - - /** - * The name of this guild - * @type {string} - */ - this.name = data.name; - - /** - * The hash of this guild's icon - * @type {?string} - */ - this.icon = data.icon; - - /** - * The hash of the guild splash image (VIP only) - * @type {?string} - */ - this.splash = data.splash; - } -} - -module.exports = PartialGuild; diff --git a/src/structures/PartialGuildChannel.js b/src/structures/PartialGuildChannel.js deleted file mode 100644 index c30c0546..00000000 --- a/src/structures/PartialGuildChannel.js +++ /dev/null @@ -1,44 +0,0 @@ -const Constants = require('../util/Constants'); - -/* -{ type: 0, id: '123123', name: 'heavy-testing' } } -*/ - -/** - * Represents a guild channel that the client only has limited information for - e.g. from invites. - */ -class PartialGuildChannel { - constructor(client, data) { - /** - * The client that instantiated this PartialGuildChannel - * @name PartialGuildChannel#client - * @type {Client} - * @readonly - */ - Object.defineProperty(this, 'client', { value: client }); - - this.setup(data); - } - - setup(data) { - /** - * The ID of this guild channel - * @type {Snowflake} - */ - this.id = data.id; - - /** - * The name of this guild channel - * @type {string} - */ - this.name = data.name; - - /** - * The type of this guild channel - `text` or `voice` - * @type {string} - */ - this.type = Constants.ChannelTypes.TEXT === data.type ? 'text' : 'voice'; - } -} - -module.exports = PartialGuildChannel; diff --git a/src/structures/VoiceChannel.js b/src/structures/VoiceChannel.js index 5234b600..9b7bd7e7 100644 --- a/src/structures/VoiceChannel.js +++ b/src/structures/VoiceChannel.js @@ -14,7 +14,7 @@ class VoiceChannel extends GuildChannel { * The members in this voice channel * @type {Collection} */ - this.members = new Collection(); + Object.defineProperty(this, 'members', { value: new Collection() }); } setup(data) {