亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Discord.py bot.command 在使用 on_message 后停止工作

Discord.py bot.command 在使用 on_message 后停止工作

白豬掌柜的 2023-10-26 15:50:19
我有一個包含 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再使用了,現在就已經過去了。


查看完整回答
反對 回復 2023-10-26
  • 1 回答
  • 0 關注
  • 147 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號