Guild's member by id
I can get that guild from id, but When I try to get that member by id, the error has occurred like below
TypeError: Cannot read properties of undefined (reading 'cache')
at Query.<anonymous> (D:\Project\minecraft\Commission\Illusion\Bot\web\server.js:64:43)
at Query.<anonymous> (D:\Project\minecraft\Commission\Illusion\Bot\node_modules\mysql\lib\Connection.js:526:10)
at Query._callback (D:\Project\minecraft\Commission\Illusion\Bot\node_modules\mysql\lib\Connection.js:488:16)
at Query.Sequence.end (D:\Project\minecraft\Commission\Illusion\Bot\node_modules\mysql\lib\protocol\sequences\Sequence.js:83:24)
at Query._handleFinalResultPacket (D:\Project\minecraft\Commission\Illusion\Bot\node_modules\mysql\lib\protocol\sequences\Query.js:149:8)
at Query.EofPacket (D:\Project\minecraft\Commission\Illusion\Bot\node_modules\mysql\lib\protocol\sequences\Query.js:133:8)
at Protocol._parsePacket (D:\Project\minecraft\Commission\Illusion\Bot\node_modules\mysql\lib\protocol\Protocol.js:291:23)
at Parser._parsePacket (D:\Project\minecraft\Commission\Illusion\Bot\node_modules\mysql\lib\protocol\Parser.js:433:10)
at Parser.write (D:\Project\minecraft\Commission\Illusion\Bot\node_modules\mysql\lib\protocol\Parser.js:43:10)
at Protocol.write (D:\Project\minecraft\Commission\Illusion\Bot\node_modules\mysql\lib\protocol\Protocol.js:38:16)
So How can I get guild's member by id?26 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
fetch
is asynchronous, but guilds will always be cached on the assumption you have the Guilds intent, so you can just access client.guilds.cache.get(<ID>)
guild members however are not always cached, so you would want to fetch that
(this is also asynchronous)Ohh
Soo How can i get member from guild?
But
guild.members
It's always return nullat no point should
guild.members
be null
care to share your updated code?please reread this message
Yeah That's return the same error
care to share your updated code for that?
do you have the Guilds intent?
are you sure your guild id is correct?
The both is require in "yes"
then where is this executing?
is it in an event?
console.log(guild.constructor.name)
I ran it on express server
But when I log the client it's work very well
like console.log(client)
that's not what I'm asking
the guild cache is only populated when your bot is logged in, so if you attempt to get a Guild from the cache outside of any client event, it's likely not logged in/ready yet
Still undefined
I solved it
Thank you for everyone 🙂
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
thank u for your idea 🙂
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Promise.prototype.then()
The then() method of a Promise object takes up to two arguments: callback functions for the fulfilled and rejected cases of the Promise. It immediately returns an equivalent Promise object, allowing you to chain calls to other promise methods.
My thread was fire Lol
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I don't know javascript very well so what's different with promise and await?
Resources to understand Promise:
• MDN: learn more
• Guide: learn more
• JavaScript info: learn more