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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

在discord.py wait_for 上使用 check() 時(shí)出現(xiàn)類型錯(cuò)誤

在discord.py wait_for 上使用 check() 時(shí)出現(xiàn)類型錯(cuò)誤

慕勒3428872 2023-12-29 10:05:30
我有一個(gè)機(jī)器人將打開(kāi)一個(gè)使用 wait_for(reaction_add) 功能的關(guān)閉民意調(diào)查。問(wèn)題是,當(dāng)我檢查作者是否做出反應(yīng)時(shí),我收到了 TypeError。這是命令:@bot.command()async def closepoll(ctx):    if not ctx.author.guild_permissions.mute_members:        await ctx.send("You cannot use this")    else:        await ctx.send("React to the poll I must close")        def check(m):            return m.author == ctx.author        try:            reaction, user = await bot.wait_for('reaction_add', timeout=120.0, check=check)        except asyncio.TimeoutError:            await ctx.send('Did not receive any reaction')        else:            message = reaction.message            if message.content.startswith("Poll:") and str(user) == str(ctx.author):                await message.edit(content="This poll is now closed.")            else:                await ctx.send("That is not a poll")但我收到錯(cuò)誤:Traceback (most recent call last):  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped    ret = await coro(*args, **kwargs)  File "hypixel.py", line 138, in closepoll    except asyncio.TimeoutError:  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/tasks.py", line 483, in wait_for    return fut.result()  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/client.py", line 339, in dispatch    result = condition(*args)TypeError: check() takes 1 positional argument but 2 were givenThe above exception was the direct cause of the following exception:
查看完整描述

1 回答

?
喵喵時(shí)光機(jī)

TA貢獻(xiàn)1846條經(jīng)驗(yàn) 獲得超7個(gè)贊

應(yīng)該采用的參數(shù)數(shù)量check取決于您正在等待的事件。反應(yīng)_add事件有兩個(gè)參數(shù),但你的函數(shù)只有一個(gè)。

嘗試用兩個(gè)參數(shù)定義一個(gè)檢查函數(shù)。例如,文檔給出了示例:

def?check(reaction,?user):
????return?user?==?message.author?and?str(reaction.emoji)?==?'??'


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

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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