R
R
RitteF2021-08-25 13:53:56
Python
RitteF, 2021-08-25 13:53:56

The reaction works 1 time, why?

I’m making a bot to support, by reaction the bot creates a channel, but it does it 1 time, after another user clicks on the reaction, nothing happens, here is the code itself:

await message_support.add_reaction("✅")
    time.sleep(5)
    while True:
        reaction, user = await client.wait_for("reaction_add")
        if str(reaction.emoji) == "✅":
            if user.id == 872913914013319188:
                return
            else:
                channel_help = await guild.create_text_channel(f"help {user}", overwrites=None, category=category, reason=None)
                await channel_help.set_permissions(ctx.guild.default_role, send_messages=False, read_messages=False, view_channel=False)
                await channel_help.set_permissions(user, send_messages=True, read_messages=True, view_channel=True)
                await channel_help.send(embed = discord.Embed(
                    title="Опишите свою проблему!",
                    colour=discord.Colour.form_rgb(255, 0, 0)
                ))
                return
        else:
            if user.id == 872913914013319188:
                return
            else:
                return

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Nevzorov, 2021-08-27
@fixator10

  1. Do not use time.sleepin asynchronous code .
  2. while Truecan also block asynchronous code unless the loop contains asynchronous calls.

Depending on your code, create a "task" (task) or handle reactions with a "listener" (listener): on_reaction_add / on_raw_reaction_add

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question