#I react and it doesn't work

1 messages · Page 1 of 1 (latest)

misty zodiac
#

I have a simple code with which you must configure with a command a message that the user writes and the bot reacts, and because the user reacts to this message gets a role, however after 1 or 2 days it stops working, my vps It is not unstable and it is from IBM and it never crashes. I would like you to know how I can make this reaction so I get it all the time because for example I cannot get from previous messages or when the bot is turned off they stop working, my question is, is there a way around this?

warm fulcrum
#

The best way would be to store the configurations in a database and load them whenever your bot starts

misty zodiac
#

I do that in fact I try to get the message because I made a database to save the message and get it to see if it reacted like that but no, after 1 or 2 days after reacting to this message the on_reaction_add does not detect it

warm fulcrum
#

How does your code in on_reaction_add?

misty zodiac
warm fulcrum
#

Just send it here

misty zodiac
#

oka

warm fulcrum
#

?tag codeblock

wind oysterBOT
#

Please put your code in a code block:
```py
Here is your Code
```

That makes reading code in Discord a lot easier:

print("This is an example.")
misty zodiac
#

ok

#
async def on_reaction_add(self, reaction: discord.Reaction, user: discord.Member):
    database = dbConnect()
    db, cursor = database.connect()

    message = reaction.message
    cursor.execute(f'SELECT * FROM verifyConfig WHERE server_guild={message.guild.id}')
    rows = cursor.fetchone()
    if rows == None:
        pass 
    else:
        if user.name == 'Zirius':
            pass 
        else:
            if str(rows[4]) == str('basic'):
                verify = message.guild.get_role(int(rows[3]))
                if verify in user.roles:
                    embed = discord.Embed(
                        title=':x: ¡Oye, ya estas verificado!',
                        color=discord.Color.orange(),
                        timestamp=datetime.datetime.now()
                    )
                    await reaction.remove(user)
                    await user.send(embed=embed)
                else:
                    if int(message.channel.id) == int(rows[1]):
                        if int(message.id) == int(rows[5]):
                            if reaction.emoji == "✅":
                                role = message.guild.get_role(int(rows[2]))
                                if role in user.roles:
                                    await reaction.remove(user)
                                    verify = message.guild.get_role(int(rows[3]))
                                    await user.add_roles(verify)

                                    cursor.execute(f'SELECT * FROM verifyWithEmbed WHERE server_guild={message.guild.id}')
                                    rows = cursor.fetchone()
                                    if rows == None:
                                        embed = discord.Embed(
                                            title=':white_check_mark: ¡Excelente, se te ha verificado!',
                                            color=discord.Color.orange(),
                                            timestamp=datetime.datetime.now()
                                        )
                                        await user.send(embed=embed)
                                    else:        
                                        color = rows[4]
                                        color = color.replace('#', '0x')
                                        int_colour = int(color,16)       

                                        title = rows[1]
                                        title = title.replace('{name}', user.name)
                                        
                                        description = rows[2]
                                        description = description.replace('{name}', user.name)

                                        embed = discord.Embed(
                                            title=title,
                                            description=description,
                                            color=int_colour,   
                                            timestamp=datetime.datetime.now()
                                        )
                                        embed.set_footer(text=rows[3])

                                        await user.send(embed=embed)
#

gets messy

warm fulcrum