Skip to content

Commit

Permalink
fix missing channels in guildCreate
Browse files Browse the repository at this point in the history
  • Loading branch information
timotejroiko committed Sep 1, 2020
1 parent 3b87289 commit ddb788c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,21 @@ Discord.Structures.extend("Guild", G => {
}
}
super._patch(d);
if(data.channels && Array.isArray(data.channels)) {
if(Array.isArray(data.channels)) {
if(this.client.options.cacheChannels) { this.channels.cache.clear(); }
for(let channel of data.channels) {
if(this.client.options.cacheChannels || this.client.channels.cache.has(channel.id)) {
this.client.channels.add(channel, this);
}
}
}
if(data.roles && Array.isArray(data.roles) && (this.roles.cache.size || this.client.options.cacheRoles)) {
if(Array.isArray(data.roles) && (this.roles.cache.size || this.client.options.cacheRoles)) {
this.roles.cache.clear();
for(let role of data.roles) {
this.roles.add(role);
}
}
if(data.members && Array.isArray(data.members)) {
if(Array.isArray(data.members)) {
for(let member of data.members) {
if(this.client.users.cache.has(member.user.id) || this.client.options.fetchAllMembers) {
this.members.add(member);
Expand All @@ -136,20 +136,20 @@ Discord.Structures.extend("Guild", G => {
this.members.fetch(this.client.user.id).catch(() => {});
}
}
if(data.presences && Array.isArray(data.presences)) {
if(Array.isArray(data.presences)) {
for(let presence of data.presences) {
if(this.client.users.cache.has(presence.user.id) || this.client.options.cachePresences) {
this.presences.add(Object.assign(presence, { guild: this }));
}
}
}
if(data.voice_states && Array.isArray(data.voice_states) && (!this.client.options.ws.intents || (this.client.options.ws.intents & Discord.Intents.FLAGS.GUILD_VOICE_STATES))) {
if(Array.isArray(data.voice_states) && (!this.client.options.ws.intents || (this.client.options.ws.intents & Discord.Intents.FLAGS.GUILD_VOICE_STATES))) {
this.voiceStates.cache.clear();
for(let voiceState of data.voice_states) {
this.voiceStates.add(voiceState);
}
}
if(data.emojis && Array.isArray(data.emojis)) {
if(Array.isArray(data.emojis)) {
if(emojis) {
this.client.actions.GuildEmojisUpdate.handle({
guild_id: this.id,
Expand Down Expand Up @@ -432,8 +432,8 @@ Discord.ChannelManager.prototype.add = function(data, guild, cache = true) {
if(cache) {
this.cache.set(channel.id, channel);
let g = channel.guild;
if(g && this.client.guilds.cache.has(g.id)) {
this.client.guilds.cache.get(g.id).channels.add(channel);
if(g && (this.client.options.cacheGuilds || this.client.guilds.cache.has(g.id))) {
g.channels.add(channel);
}
}
return channel;
Expand Down

0 comments on commit ddb788c

Please sign in to comment.