python - I got error while getting all the list of members from guild
问题描述
I used async for member in guild.fetch_members(limit=None):
to get all the members from the chosen guild and I already tried to set the bot's permission to administrator and top of everyone, but still, there is the same problem. I want to get all the lists of members' IDs from a single guild.
Traceback (most recent call last):
File "discord\client.py", line 312, in _run_event
File "Stock.py", line 85, in on_message
File "discord\iterators.py", line 86, in __anext__
File "discord\iterators.py", line 605, in next
File "discord\iterators.py", line 627, in fill_members
File "discord\http.py", line 241, in request
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
解决方案
if you have the guild
object you can get all member id
in the specific guild by this code
member_id_list = [ member.id for member in guild.members ]
I used guild.members to get all member object in the guild and iterate through it and saved every member id in member_id_list
list. read document for more info!
NOTE: make sure that you enabled SERVER MEMBERS INTENT
in your discord developer portal! and add this in your code!
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix='&',intents = intents)
because without that your bot can't fetch all members in the guild!
推荐阅读
- c++ - 为什么在 LeetCode 的 3Sum 问题中显示运行时错误?
- typescript - 更新 Apollo 客户端使用的动态端点
- python - 使用字符串作为 numpy 数组的名称
- java - 如何以用户(而非管理员)身份从 Java 客户端访问 Google Firestore?
- javascript - Redis流命令传递带有解析值的消息
- python - 错误:函数“AddmmBackward”在其第二个输出中返回了 nan 值
- javascript - 如何使用 HttpServletResponse setHeader() 从控制器向目标 HTML 页面发送重定向参数
- .net-core - 如何在 IHost 启动时运行同步任务
- python - 如何使用 Python Selenium
- web - 如果我将它分配给新的实例/IP,域年龄会重新计算吗?