Fix inconsistency with Channel Creation: CustomStructures (#2121)

* Fix inconsistancy with Channel Creation

* Because static get is a function, it thinks we are create a new instance based on that function, rather than the returned class...
This commit is contained in:
bdistin
2017-11-24 21:42:02 -06:00
committed by Schuyler Cebulskie
parent f3817e328b
commit dcf48e2225
2 changed files with 20 additions and 11 deletions

View File

@@ -66,32 +66,37 @@ class Channel extends Base {
} }
static create(client, data, guild) { static create(client, data, guild) {
const DMChannel = require('./DMChannel'); const Structures = require('../util/Structures');
const GroupDMChannel = require('./GroupDMChannel');
const TextChannel = require('./TextChannel');
const VoiceChannel = require('./VoiceChannel');
const CategoryChannel = require('./CategoryChannel');
const GuildChannel = require('./GuildChannel');
let channel; let channel;
if (data.type === ChannelTypes.DM) { if (data.type === ChannelTypes.DM) {
const DMChannel = Structures.get('DMChannel');
channel = new DMChannel(client, data); channel = new DMChannel(client, data);
} else if (data.type === ChannelTypes.GROUP) { } else if (data.type === ChannelTypes.GROUP) {
const GroupDMChannel = Structures.get('GroupDMChannel');
channel = new GroupDMChannel(client, data); channel = new GroupDMChannel(client, data);
} else { } else {
guild = guild || client.guilds.get(data.guild_id); guild = guild || client.guilds.get(data.guild_id);
if (guild) { if (guild) {
switch (data.type) { switch (data.type) {
case ChannelTypes.TEXT: case ChannelTypes.TEXT: {
const TextChannel = Structures.get('TextChannel');
channel = new TextChannel(guild, data); channel = new TextChannel(guild, data);
break; break;
case ChannelTypes.VOICE: }
case ChannelTypes.VOICE: {
const VoiceChannel = Structures.get('VoiceChannel');
channel = new VoiceChannel(guild, data); channel = new VoiceChannel(guild, data);
break; break;
case ChannelTypes.CATEGORY: }
case ChannelTypes.CATEGORY: {
const CategoryChannel = Structures.get('CategoryChannel');
channel = new CategoryChannel(guild, data); channel = new CategoryChannel(guild, data);
break; break;
default: }
default: {
const GuildChannel = Structures.get('GuildChannel');
channel = new GuildChannel(guild, data); channel = new GuildChannel(guild, data);
}
} }
guild.channels.set(channel.id, channel); guild.channels.set(channel.id, channel);
} }

View File

@@ -61,8 +61,12 @@ class Structures {
} }
const structures = { const structures = {
Channel: require('../structures/Channel'),
Emoji: require('../structures/Emoji'), Emoji: require('../structures/Emoji'),
DMChannel: require('../structures/DMChannel'),
GroupDMChannel: require('../structures/GroupDMChannel'),
TextChannel: require('../structures/TextChannel'),
VoiceChannel: require('../structures/VoiceChannel'),
CategoryChannel: require('../structures/CategoryChannel'),
GuildChannel: require('../structures/GuildChannel'), GuildChannel: require('../structures/GuildChannel'),
GuildMember: require('../structures/GuildMember'), GuildMember: require('../structures/GuildMember'),
Guild: require('../structures/Guild'), Guild: require('../structures/Guild'),