Z_runner
Z_runner
DIAdiscord.js - Imagine an app
Created by Z_runner on 7/17/2023 in #djs-questions
`Cannot read properties of undefined (reading 'send')` when fetching guild members
Hi! I got some weird error while fetching the members list of my guild. I believe this is a lib bug, but I want to make sure I didn't miss anything on my side My code:
const guild = await this.getClient().guilds.fetch(guildId);
const members = await guild.members.fetch();
const guild = await this.getClient().guilds.fetch(guildId);
const members = await guild.members.fetch();
the error:
[ERROR] TypeError: Cannot read properties of undefined (reading 'send')
at .../node_modules/discord.js/src/managers/GuildMemberManager.js:237:24
at new Promise (<anonymous>)
at GuildMemberManager._fetchMany (.../node_modules/discord.js/src/managers/GuildMemberManager.js:235:12)
at GuildMemberManager.fetch (.../node_modules/discord.js/src/managers/GuildMemberManager.js:207:31)
...
[ERROR] TypeError: Cannot read properties of undefined (reading 'send')
at .../node_modules/discord.js/src/managers/GuildMemberManager.js:237:24
at new Promise (<anonymous>)
at GuildMemberManager._fetchMany (.../node_modules/discord.js/src/managers/GuildMemberManager.js:235:12)
at GuildMemberManager.fetch (.../node_modules/discord.js/src/managers/GuildMemberManager.js:207:31)
...
and the d.js code leading to this error:
this.guild.shard.send({
op: GatewayOpcodes.RequestGuildMembers,
d: {
guild_id: this.guild.id,
presences,
user_ids: users,
query,
nonce,
limit,
},
});
this.guild.shard.send({
op: GatewayOpcodes.RequestGuildMembers,
d: {
guild_id: this.guild.id,
presences,
user_ids: users,
query,
nonce,
limit,
},
});
(guild.shard is indeed undefined when printed on console)
61 replies