【发布时间】:2021-05-07 15:49:24
【问题描述】:
我想创建一个带有默认前缀的命令来重置我的机器人的当前前缀。
@bot.command()
async def prefix(ctx, arg):
bot.command_prefix = arg
await ctx.send("You prefix has been updated to: "+str(arg))
@bot.event()
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith("-reset"):
bot.command_prefix = "-"
await ctx.send("You prefix has been reseted to: -")
当我执行它时,只有bot.event() 部分有效。我没有收到任何错误,但 bot.command() 代码不起作用
【问题讨论】:
-
你为什么使用
bot.command和in-on_message命令?
标签: python discord.py