Skip to content

Commit

Permalink
Set channel.guild in Guild constructor
Browse files Browse the repository at this point in the history
Logical circular dependencies are fun. Since the guild hasn't been added to client.guilds yet, the
guild won't be found in the GuildChannel constructor
  • Loading branch information
abalabahaha committed Nov 23, 2019
1 parent 236dbf4 commit c323213
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ class Guild extends Base {
}

if(data.channels) {
for(const channel of data.channels) {
this.channels.add(Channel.from(channel, client));
for(const channelData of data.channels) {
channelData.guild_id = this.id;
const channel = Channel.from(channelData, client);
channel.guild = this;
this.channels.add(channel, client);
client.channelGuildMap[channel.id] = this.id;
}
}
Expand Down

0 comments on commit c323213

Please sign in to comment.