最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

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

Discord.py、bot.event 有效,但 bot.command 無效

Discord.py、bot.event 有效,但 bot.command 無效

寶慕林4294392 2023-12-09 16:05:09
因此,如果我實現(xiàn)了 bot.event,bot.command 就不起作用,但如果我評論或刪除 bot.event,bot.command 就可以正常工作。在這里,bot.command 不起作用,但 bot.event 起作用:# bot.pyimport osfrom discord.ext import commandsfrom dotenv import load_dotenvload_dotenv()TOKEN = os.getenv('DISCORD_TOKEN')bot = commands.Bot(command_prefix='dedmu ')@bot.eventasync def on_ready():    print(f'{bot.user.name} has connected to Discord!')@bot.eventasync def on_message(message):    if message.author == bot.user:        return    if message.content.lower() == 'testt':        await message.channel.send('it works')@bot.command(name='test')async def test(ctx, arg):    await ctx.send(arg)bot.run(TOKEN)如果我用 bot.event 注釋這兩個函數(shù),則 bot.command 可以完美工作。它出什么問題了?:<
查看完整描述

1 回答

?
手掌心

TA貢獻(xiàn)1942條經(jīng)驗 獲得超3個贊

因為你有一個on_message活動。當(dāng)您的機(jī)器人中有on_message事件時,您需要await bot.process_commands(message)在事件代碼的最后一行添加on_message。否則它將阻止命令工作。



查看完整回答
反對 回復(fù) 2023-12-09
  • 1 回答
  • 0 關(guān)注
  • 189 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號