【发布时间】:2019-09-03 22:25:12
【问题描述】:
Disocord.py 重写
错误: 否
以下命令未按预期工作
@bot.event
async def on_message(message):
x = (559253532759425044)
er = bot.get_channel(559253532759425044)
if not message.channel.id != x:
return
else:
if "p/" in message.content.lower():
await message.channel.send('Write this command in {}'.format(er.mention))
p/是bots前缀,上面这段代码告诉(在{}'.format(er.mention)中写这个命令)什么时候使用p/正确的 channl 机器人什么也没说,但我使用任何命令,如 p/help 它不起作用。实际上该事件应该允许成员使用机器人命令 (@bot.command)仅在指定的频道中,而不是任何其他频道,但事情是没有命令在指定的频道或服务器中的任何频道中起作用。任何帮助都会很棒:) 编辑:(指定我的问题并说清楚)
【问题讨论】:
-
if not message.channel.id != x:你这里有一个双重否定 notmessage.channel.idnot 等于x。它应该只是if message.channel.id != x- 删除 not。 -
x也不需要括号中的频道ID -
不明白你所说的,先生,你能不能更深入地解释一下,我也想要它,就像我不必在我做的每个命令中写东西一样
-
当你说命令时,是不是指
commands扩展,即用@bot.command装饰的协程? -
是的,我的意思是@bot.command
标签: bots discord discord.py-rewrite