Remove partial classes (#1794)

* remove partial objects

* remove partial evil

* Update Invite.js

* Update Invite.js
This commit is contained in:
Gus Caplan
2017-08-17 11:49:41 -07:00
committed by Crawl
parent fff8b764af
commit 9b97fe292f
6 changed files with 12 additions and 110 deletions

View File

@@ -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'),

View File

@@ -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<Snowflake, Emoji>}
*/
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,

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -14,7 +14,7 @@ class VoiceChannel extends GuildChannel {
* The members in this voice channel
* @type {Collection<Snowflake, GuildMember>}
*/
this.members = new Collection();
Object.defineProperty(this, 'members', { value: new Collection() });
}
setup(data) {