我有一個包含 bot.command 和 bot.event 的腳本,但由于某種原因只有 bot.command 正在工作bot.command 和 bot.event 單獨工作,但由于某種原因不能一起工作這是代碼:# bot.pyimport discordfrom discord.ext import commandsfrom discord.utils import getTOKEN = ('token')bot = commands.Bot(command_prefix=',')@bot.eventasync def on_ready(): print(f'{bot.user} has connected to Discord!')@bot.eventasync def on_message(message): if foo: await message.channel.send("foo")@bot.command(pass_context=True)async def foo(ctx, args): foo = bot.get_user(args) await ctx.send(foo)bot.run(TOKEN)謝謝
1 回答

慕后森
TA貢獻1802條經驗 獲得超5個贊
您需要on_message
處理機器人的命令:
await bot.process_commands(message)
而且你也不需要pass_context=True
再使用了,現在就已經過去了。
添加回答
舉報
0/150
提交
取消