python - Discord.py fetch_members 缺少访问权限
问题描述
我需要从指定的不和谐服务器获取所有成员的列表。
我怎么做?
错误:
Traceback (most recent call last):
File "/home/sergiuf/.local/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 903, in invoke
await ctx.command.invoke(ctx)
File "/home/sergiuf/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 859, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/sergiuf/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 50001): Missing Access
代码:
@commands.command()
@commands.has_permissions(administrator=True)
async def members(self,ctx):
with open('users.txt','w') as f:
async for member in ctx.guild.fetch_members(limit=None):
print("{},{}".format(member,member.id), file=f,)
print("done")
解决方案
推荐阅读
- mongodb - 在不知道其命名空间的情况下重命名 mongo 集合
- pandas - 使用python将文件保存在不同的文件夹中
- terraform - 如果 Terraform 中的 Resource.Schema 属性发生更改,请避免触发更新
- c# - EmptyCell:在 AddNew 或 EditItem 事务期间不允许 DeferRefresh
- vue.js - 可以从 vuex 中创建的钩子中调用 getter 吗?
- php - 对象创建规范的语法?
- amazon-web-services - AWS Lambda 使用容器映像在设备上抛出没有空间
- javascript - 如何在计算器应用程序颤振中添加功能
- vba - 如何将日期范围标准添加到电子邮件导入
- sql - sql 根据其他行中的值进行选择