【发布时间】:2020-10-10 17:55:35
【问题描述】:
我正在尝试创建一个日志设置命令,例如:“消息编辑日志会打开吗?”如果是:发送频道 ID。我试图创建的命令与此类似。我的代码是这样的。我是 discord.py 的菜鸟。这是代码,感谢您的帮助。
注意:执行命令时我没有得到任何输出。
@bot.command(name="logsetup")
@commands.guild_only()
@commands.has_any_role("Head Admininstaror", "Adminstaror", "Owner")
async def log_setup(self, ctx):
await ctx.send("Message edit logs: On/Off")
msg = await bot.wait_for('message', check=lambda message: message.author == ctx.author)
if msg.content.lower() == "on":
print("Working.")
await ctx.send("Send the channel ID.")
msg = await bot.wait_for('message', check=lambda message: message.author == ctx.author)
editedMessageChannel = msg.content
ctx.send("Channel is set.")
【问题讨论】:
-
您在结尾处缺少
awaitctx.send -
是的,你是对的,但即使发送通道 id 也没有执行,也没有错误。
-
我刚刚在我的机器人上运行了它。将 await 添加到
ctx.send("Channel is set.")时效果很好。哦,因为它看起来像是在齿轮中,所以请确保在bot位之前添加self.。例如msg = await self.bot.wait_for(' etc... -
你可以像
commands.command(name='fun', aliases=['a', 'b'])这样传递命令名和别名
标签: python discord discord.py