首页 > 解决方案 > 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")

标签: pythondiscord

解决方案


推荐阅读