Accessing Specific Guild from Bot's Cache is not working

I hope this message finds you well. I am currently facing an issue with my Discord bot, and I'm seeking some guidance from the community. Here's the problem I'm encountering: 1. When my bot joins a new guild, I can successfully access that guild using the Events.GuildCreate event. I retrieve it from the cache using client.guilds.cache. 2. However, when I attempt to access a specific guild from the cache using the same client instance, I am getting "undefined." Additionally, when I check the Collection map, it appears to be empty. I'm puzzled by this behavior and unsure why it's happening. Is there something I might be missing or doing incorrectly? Am sharing my bot scopes, codes and output that am getting
14 Replies
d.js toolkit
d.js toolkit2y ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
fahimfaisaal
fahimfaisaalOP2y ago
Joining bot code and logs
fahimfaisaal
fahimfaisaalOP2y ago
Accessing the guild by id and loging the cache
treble/luna
treble/luna2y ago
do you have the Guilds intent
fahimfaisaal
fahimfaisaalOP2y ago
this?
treble/luna
treble/luna2y ago
then you dont need to manually cache the guild
fahimfaisaal
fahimfaisaalOP2y ago
fahimfaisaal
fahimfaisaalOP2y ago
yeah it wasn't working so i tried by adding manually
treble/luna
treble/luna2y ago
How did you define client
fahimfaisaal
fahimfaisaalOP2y ago
Sorry, didn't get you.
treble/luna
treble/luna2y ago
How and where did you define discordClient and how do you call the function Because it might not be logged in If you use the guildCreate event, use <Guild>.client
fahimfaisaal
fahimfaisaalOP2y ago
I defiend my client inside backend config and accessed the client from there in many services inside nx mono repo. am logging the client by this function
fahimfaisaal
fahimfaisaalOP2y ago
Am getting guilds from there, but not from another service inside my Monorepo But the client is same
treble/luna
treble/luna2y ago
Use <Guild>.client, most djs structures have a client property present
Want results from more Discord servers?
Add your server