第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

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

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

ibeautiful 2023-12-12 10:00:08
因此,如果我實現(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 回答

?
BIG陽

TA貢獻1859條經(jīng)驗 獲得超6個贊

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



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

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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