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?
#I react and it doesn't work
1 messages · Page 1 of 1 (latest)
The best way would be to store the configurations in a database and load them whenever your bot starts
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
How does your code in on_reaction_add?
It is a small verification system, if you want I can send you the code to DM
Just send it here
oka
?tag codeblock
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.")
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
Well, according to the docs. on_reaction_add only works if the message is cached. Use on_raw_reaction_add instead.
https://docs.pycord.dev/en/stable/api/events.html#discord.on_raw_reaction_add