首页 > 解决方案 > discord.py 某些人执行命令

问题描述

所以我试图发出一个只有我和另一个人可以关闭机器人的注销命令,


trusted = {id, id}
    @commands.command()
    async def test(self, ctx):
        if ctx.author.id  in trusted:       
            await ctx.send(f"{ctx.author.mention} Closing Bot")
            await self.bot.close()
        else:
            await ctx.send("Only (me) and (my friend) can execute this")

出于某种原因,每当我尝试这样做时,它都没有意识到我是受信任的并且不会执行。

标签: pythondiscord.py

解决方案


intents.members启用了吗?如果不:

intents = discord.Intents.default()
intents.members = True

bot = commands.Bot(..., intents=intents)

还要确保在开发人员门户中启用它们

参考


推荐阅读