python - 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")
出于某种原因,每当我尝试这样做时,它都没有意识到我是受信任的并且不会执行。
解决方案
你intents.members
启用了吗?如果不:
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(..., intents=intents)
还要确保在开发人员门户中启用它们
推荐阅读
- django - Django 查询集分组
- javascript - 在屏幕中间滚动元素的方式
- angular - 我在角度 6 中遇到了父组件方法的问题
- javascript - Javascript 不返回 AJAX 数据(JSON、PHP、AJAX)
- angular - 在 Ionic 的 html 文件中声明后如何将值更改为变量?
- c# - 制作多对多数字匹配器的更有效方法
- java - Elasticsearch java客户端初始化失败
- security - 不是所有通过网络服务器进行的数据交换都容易被拦截吗?
- arrays - Angular 7/Typescript:创建队列/方法数组
- algorithm - 替代和顺序结构算法