0

I wanted to know is there a way to send a message like: Only *user can react to this message and save the message id to the json file. then if someone reacts to that specific message and the user is the user in the json file it does something. I'm using disnake https://disnake.dev/ Thx

I have tried

message = await message.channel.send("Test REACTION")
        await message.add_reaction("❌")
        def check(reaction, user):
            return user == message.author and str(reaction.emoji) in ["❌"] and reaction.message == message

        approve = await bot.wait_for("reaction_add", check=check)

        if approve:
            await message.channel.send("Reaction added!")

but it would reply Reaction added! when the bot reacted + i want it to be stored in a database so it checks if the message id is the message id in the database.

SkyLi000
  • 21
  • 3

1 Answers1

0

If i understand you correctly you only want to check if a specific user reacted to a specific message. You could use the on_raw_reaction_add() event for this.

  1. You create a command to put a specific msg into the json file + the mentioned user
  2. You create a event which listens to all messages which are inside the json file so the bot can check if the reaction user is equal to the one in the json file.

Here is an example of how the event would look like:

import disnake
from disnake.ext import commands

intents = disnake.Intents.default() 
intents.reactions = True #intents needed

client = commands.Bot(command_prefix=".", intents=intents)

@client.event
async def on_raw_reaction_add(payload):
    channel = client.get_channel(payload.channel_id) #get the channel of the message
    message_id = payload.message_id
    if message_id == 5571658637258252626: #id of the message
        if payload.emoji.name == '❌': #if user reacted with specific emoji 
            if payload.user_id == 28756535695656583: #user id of the user who is allowed to react
                return await channel.send("You are allowed to do this.") #sending message to confirm
            else: #users who are not allowed to react
                return await channel.send("You are not allowed to do this.") #sending message to confirm



client.run("token")

   

boez
  • 331
  • 1
  • 8