Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read properties of undefined (reading 'send') #9729

Closed
vitu0089 opened this issue Jul 20, 2023 · 6 comments
Closed

TypeError: Cannot read properties of undefined (reading 'send') #9729

vitu0089 opened this issue Jul 20, 2023 · 6 comments

Comments

@vitu0089
Copy link

Which package is this bug report for?

discord.js

Issue description

While I was building a localized leaderboard for my bot, I used a .fetch() command. It worked fine while building, but shortly after I released it, it stopped working, giving me the error in the title. It's got something to do with a missing shard in the Guild object, but it's not my code throwing an error, it's the discord module.

I've looked for solutions on here already, but people saying that the bot not being logged in might be the issue, but I can do all the other commands just fine, but when I do a local leaderboard command, executing the code below, it crashes, with the error at the bottom.

Here is the simplified version of the code, Guild being the native Discord guild object

var Members =  await Guild.members.fetch()
console.log(Members)

Error:

Uncaught TypeError TypeError: Cannot read properties of undefined (reading 'send')
    at <anonymous> (c:\Users\Me\Documents\Code\TypeScript\Bot Handler\Bots\Anagram Bot\node_modules\discord.js\src\managers\GuildMemberManager.js:237:24)
    at _fetchMany (c:\Users\Me\Documents\Code\TypeScript\Bot Handler\Bots\Anagram Bot\node_modules\discord.js\src\managers\GuildMemberManager.js:235:12)
    at fetch (c:\Users\Me\Documents\Code\TypeScript\Bot Handler\Bots\Anagram Bot\node_modules\discord.js\src\managers\GuildMemberManager.js:207:31)
    at <anonymous> (c:\Users\Vitus Petersen\Documents\Learning Code\TypeScript\Bot Handler\Bots\Anagram Bot\index.js:138:80)
    at fulfilled (c:\Users\Me\Documents\Code\TypeScript\Bot Handler\Bots\Anagram Bot\index.js:28:58)
    at processTicksAndRejections (internal/process/task_queues:95:5)

Code sample

var Members =  await Guild.members.fetch()
console.log(Members)

Versions

"discord.js": "^14.11.0"

Issue priority

Low (slightly annoying)

Which partials do you have configured?

Channel

Which gateway intents are you subscribing to?

Guilds, GuildMembers, GuildMessages, GuildMessageReactions, DirectMessages, MessageContent

I have tested this issue on a development release

d26e022

@Jiralite
Copy link
Member

Jiralite commented Jul 20, 2023

I've looked for solutions on here already, but people saying that the bot not being logged in might be the issue

That is the issue. If your client logs in, you receive shard data and guild objects are populated with that.

@Jiralite Jiralite closed this as not planned Won't fix, can't repro, duplicate, stale Jul 20, 2023
@vitu0089
Copy link
Author

Explain to me how I can do all other commands and use the bot as usual, but the only thing that it can't do is fetch the members? Wouldn't it have to be logged in to do all those things as well?

@Jiralite
Copy link
Member

but the only thing that it can't do is fetch the members?

That requires a gateway connection. The others do not.

@vitu0089
Copy link
Author

How about fetching commands? It does that just fine

@vitu0089
Copy link
Author

I'm really confused here, what am I supposed to do to fix this, if it's really on my side? I did Client.login("Token") 2 minutes prior to me doing the command, and I don't know what you mean by gateway connection, so that doesn't bring me too far.

@discordjs discordjs locked as off-topic and limited conversation to collaborators Jul 20, 2023
@monbrey
Copy link
Member

monbrey commented Jul 20, 2023

The issue tracker is only for bug reports and enhancement suggestions. If you have a question, please ask it in the Discord server instead of opening an issue – you will get redirected there anyway.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants