javascript - why does discord.js not let me do guild.members.fetch()? - Stack Overflow

When I try and run membermanager.fetch(); (documentation), I get the error Error [GUILD_MEMBERS_TIMEOUT

When I try and run membermanager.fetch(); (documentation), I get the error Error [GUILD_MEMBERS_TIMEOUT]: Members didn't arrive in time.

I have quite a good internet connection and I've tried giving it more time. This happens both on my test server with about 10 members and the server its intended for with about 30. membermanager.cache doesn't suffice for my use case. It's not a temporary problem as this was also happening yesterday. My discord.js version is 12.4.1 and I updated it this morning. If it helps the bot is written in typescript.

I've noticed it works if I pass the query parameter as a non-empty string or user as an array of user ids, but I assume the discord.js source code is calling a different method entirely.

This has properly left me stumped. If you could help that would be much appreciated.

When I try and run membermanager.fetch(); (documentation), I get the error Error [GUILD_MEMBERS_TIMEOUT]: Members didn't arrive in time.

I have quite a good internet connection and I've tried giving it more time. This happens both on my test server with about 10 members and the server its intended for with about 30. membermanager.cache doesn't suffice for my use case. It's not a temporary problem as this was also happening yesterday. My discord.js version is 12.4.1 and I updated it this morning. If it helps the bot is written in typescript.

I've noticed it works if I pass the query parameter as a non-empty string or user as an array of user ids, but I assume the discord.js source code is calling a different method entirely.

This has properly left me stumped. If you could help that would be much appreciated.

Share Improve this question asked Oct 27, 2020 at 15:38 radiishradiish 2182 silver badges9 bronze badges 6
  • What exactly are you trying to do? – user14023978 Commented Oct 27, 2020 at 15:40
  • Do you have the GUILD_MEMBERS intent enabled? – Lioness100 Commented Oct 27, 2020 at 15:45
  • @Lioness100 how do I enable that? – radiish Commented Oct 27, 2020 at 15:48
  • Check my answer to this question – Lioness100 Commented Oct 27, 2020 at 15:49
  • @Lioness100 you're a lifesaver! – radiish Commented Oct 27, 2020 at 15:51
 |  Show 1 more ment

1 Answer 1

Reset to default 8

Answering my own question here.

Turns out I didn't have the GUILD_MEMBERS intent set. A quick fix from this:

import { Client, Intents } from "discord.js";
export const client: Client = new Client();

to something that included intents:

import { Client, Intents } from "discord.js";
let intents = new Intents(Intents.NON_PRIVILEGED);
intents.add('GUILD_MEMBERS');
export const client: Client = new Client({ ws: {intents: intents} });

and a fix in the discord developer portal. That's all it needed.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744206811a4563143.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信