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

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

如何讓機(jī)器人只響應(yīng)同一消息的 add_reaction?

如何讓機(jī)器人只響應(yīng)同一消息的 add_reaction?

喵喔喔 2023-06-13 10:37:39
def isAdmin(reaction, user):    for i in admins:        if user.id == i: return (str(reaction.emoji) == '??' or str(reaction.emoji) == '??')try: reaction, user = await self.bot.wait_for('reaction_add', timeout=43200, check=isAdmin)except asyncio.TimeoutError: await msg.edit(embed=embedEnd)else:    resign_channel = discord.utils.get(ctx.guild.channels, name="resignings")     if str(reaction.emoji) == '??':        print('{}: {} resigned {} {}.'.format(extCalls.timeNow('datetime'), ctx.channel.category.name, firstName, lastName))        await msg.edit(embed=embedFin)        await resign_channel.send(embed=embedConf)    else: await msg.edit(embed=embedEnd)這是我的代碼,讓機(jī)器人等待對msg. 但是,由于某種原因,當(dāng)我msg同時有兩條(消息)等待反應(yīng)時,當(dāng)我對一條消息作出反應(yīng)時,即使我沒有對第二條消息做出反應(yīng),都會觸發(fā)成功。這對于基于管理員的審批系統(tǒng)來說是個大問題……有誰知道為什么會這樣或如何解決?
查看完整描述

1 回答

?
蕪湖不蕪

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

這段代碼真的很亂,但是如果你正在尋找一種只等待對一條消息的反應(yīng)的方法,你應(yīng)該在你的檢查命令中添加一些東西,例如:


@bot.command(name="some_command")

async def sc(ctx):

    msg = await ctx.send("Some interesting message!")

    def check(reaction, user):

        return reaction.message.id == msg.id

    try:

        reaction, user = await bot.wait_for("reaction_add", check=check,timeout=30.0)

    except asyncio.TimeoutError:

        await ctx.send("timeout")

        return

    await ctx.send(f"You reacted {str(reaction)}")


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

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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