discord.py:等待超时,尽管没有超时

2024-09-29 19:32:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个带有wait_for的命令,如果该命令被执行,bot将向特定通道发送消息。现在,机器人应该等到一个特定的反应被加入。但在某些消息中,如果添加了特定的反应,则bot不会做出反应。我认为它超时了,尽管我把它设置为“无”。 很可能有几个人同时使用该命令。我不知道这是否是个问题

代码:

@bot.command(aliases=['Buy'])
async def buy(ctx, choice = None):
    if ctx.guild.id == BlackTVServerID:

        channel = bot.get_channel(705836078082424914)
        channeluser = bot.get_channel(705146663135871106)
        userauthor = ctx.message.author
        vcrole1 = get(userauthor.guild.roles, id=703562188224331777)


        guildemojisbtv = bot.get_guild(712671329123303504)
        Evbucks = get(guildemojisbtv.emojis, id=713138458071269551)
        Erotinfo = get(guildemojisbtv.emojis, id=712677573498372097)
        Epositiv = get(guildemojisbtv.emojis, id=712679512873369610)
        Echeck = get(guildemojisbtv.emojis, id=712726333058318417)
        Eladen = get(guildemojisbtv.emojis, id=713168533416181879)
        Eerror = get(guildemojisbtv.emojis, id=713187214586282054)

        messagechannel = ctx.message.channel.id
        if ctx.message.channel.id in [705146663135871106, 707209203755909190]:
            if choice == '1':
                if any(role.id == 703562188224331777 for role in ctx.message.author.roles):
                    with open(r'./buylimit.json', 'r')as f:
                        userslimitbuy = json.load(f)
                    if not f"{userauthor.id}" in userslimitbuy:
                        userslimitbuy[f"{userauthor.id}"] = f'{userauthor}'
                        with open(r'./buylimit.json', 'w') as f:
                            json.dump(userslimitbuy, f, indent=4)

                        embed = discord.Embed(color=farbegruen, description=
                        f'\n{Epositiv} **5.000{Evbucks} eingefordert!** `Geld wird innert 24 Stunden hinzugefügt`')
                        embed.set_author(name=f'{ctx.message.author}', icon_url=f'{ctx.message.author.avatar_url}')
                        await ctx.send(embed=embed)
                        try:
                            embedblock = discord.Embed(color=0xe02522,
                                                       description=f'{Erotinfo} Du kannst nur **einmal Casino-Geld pro Shop Öffnung** kaufen!'
                                                                   '\nSomit ist der Command `!buy` nun für dich bis nächste Woche **gesperrt!**')
                            await userauthor.send(embed=embedblock)
                        except discord.Forbidden:
                            pass

                        embed = discord.Embed(color=0xe02522, title='**__Kauf von Casino Geld__**', description=
                        f'**User**: {userauthor.mention}'
                        f'\n_ _'
                        f"\n**Geld**: 5,000"
                        f"\n**Gekauft mit**: <@&703562188224331777>"
                        f"\n**Gekauft im**: <#{messagechannel}>"
                        f"\n"
                        f"\nReagiere mit {Echeck}, falls erledigt!!")
                        embed.set_footer(text=f'Gekauft am ')
                        embed.timestamp = datetime.datetime.utcnow()

                        mess1 = await channel.send(embed=embed)
                        await mess1.add_reaction(f'{Echeck}')

                        def check(reactionbuy, userbuy):
                            return str(
                                reactionbuy.emoji) == f'{Echeck}' and reactionbuy.message.channel.id == 705836078082424914 and not userbuy.bot and reactionbuy.message.id == mess1.id

                        reaction, user = await bot.wait_for('reaction_add', check=check, timeout=None)
                        checkreact = Echeck
                        await mess1.clear_reaction(checkreact)
                        print('registriert')
                        await mess1.edit(
                            embed=discord.Embed(color=farbegruen, title='__**Casino-Geld ausgezahlt**__', description=
                            f'**User**: {userauthor.mention}'
                            f'\n_ _'
                            f"\n**Geld**: 5,000"
                            f"\n**Gekauft mit**: <@&703562188224331777>"
                            f"\n**Gekauft im**: <#{messagechannel}>"
                            f"\n"
                            f"\n**CASINO-GELD AUSGEZAHLT** von {user.mention}"))
                        try:
                            embedgeld = discord.Embed(color=farbegelb,
                                                      description=f'{Eladen} `Dein angefordertes Casino-Geld ist in Bearbeitung...`'
                                                                  f'\nBetrag: **5.000**{Evbucks}')
                            messembedgeld = await userauthor.send(embed=embedgeld)
                            await asyncio.sleep(10)
                            await messembedgeld.edit(embed=discord.Embed(color=farbegruen,
                                                                         description=f'{Epositiv} `Dein angefordertes Casino-Geld wurde auf deine Bank überwiesen!`'
                                                                                     f'\nBetrag: **5.000**{Evbucks}'))
                        except discord.Forbidden:
                            pass

                    else:
                        embedschongekauft = discord.Embed(color=farberot, description=
                                                          f'{Eerror} {userauthor.mention} Du hast heute bereits gekauft!')
                        await ctx.send(embed=embedschongekauft)

我没有注意到任何错误,因为我在VPS上主持了这段时间


Tags: idmessagegetbotchannelembeddescriptionawait

热门问题