公会成员不再填充,不能GetUserAsync,因为它仅返回bot,而没有其他人 [英] Guild members are not populated anymore, cannot GetUserAsync as it only returns the bot and no one else

查看:50
本文介绍了公会成员不再填充,不能GetUserAsync,因为它仅返回bot,而没有其他人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,我无法再从该机器人所在的公会中获取任何成员.

For some reason I cannot get any members anymore from the guild the bot is in.

为确保我有用户,我用

        DiscordSocketConfig config = new DiscordSocketConfig { AlwaysDownloadUsers = true };
        client = new DiscordSocketClient(config);

我响应的事件在连接后很长时间.它将从机器人所在的公会中的渠道本身中获取消息,因此该机器人已连接,正在运行,并且可以看到所有成员.

The event I respond to is long after it has connected. It will pick up messages from the channels themselves in the guild the bot is in, so it's connected, working, and can see all of the members.

我遍历了所有成员,并尝试使用一些调试代码将它们打印出来:

I go through all the members and I'm trying to print them out with some debug code like:

        Console.WriteLine("Users:");
        foreach (IGuildUser? u in Guild.GetUsersAsync().Result)
            Console.WriteLine($"    {u.Username} ({u.Id})");

,它只会打印自己.

我在代码中使用此代码的方式如下:

The way I'm using this in my code is like:

Guild.GetUserAsync(user.Id)  // user is valid, this is empty for anyone who is not the bot

公会对象上的私有字段 _members 具有1个元素(它本身就是机器人),但其他所有元素(例如: _emojis _channels ,以及其他任何缓存的内容).该bot可以在频道中与所有用户聊天,也可以在频道中与所有用户接收消息,因此我不知道为什么它无法获得所有成员.

The private field _members on the guild object has 1 element (which is itself, the bot), but all the other things (ex: _emojis, _channels, any other cached thing) are all fully populated. The bot can talk in channels and receive messages in channels with all the users as well, so I have no idea why it cannot get all the members.

最让我感到困惑的是,这一切都在起作用,然后魔术般地停止了一整夜的工作.公会已经有100多个成员了,所以我不明白为什么它现在突然失败了.

What confuses me the most is that this was all working, and then magically stopped working overnight. The guild has been over 100 members for a while, so I don't understand why it's suddenly failing now.

最重要的是,该机器人具有我所拥有的所有角色,因此它不可能神奇地无法看到其成员.我可以排除机器人的视觉问题.

Most importantly, the bot has all the roles that I have, so there's no way it's magically unable to see the members. I can rule out any visual problems for the bot.

有什么办法可以调试吗?我想念什么吗?我如何让行会的所有成员重新工作?

Any way I can debug this? Am I missing something? How can I get all the members of a guild to work again?

推荐答案

这是Discord强制

This is a result of Discord enforcing intents.

意图允许您选择加入某些网关事件.当前,GUILD_MEMBERS和GUILD_PRESENCES意图是特权意图".并具有以下效果:

Intents allow you to opt-in to certain gateway events. Currently, the GUILD_MEMBERS and GUILD_PRESENCES intents are "privileged intents" and have the following effects:

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆