I'm trying to build a bot that detects a specific emoji. When bot gets this, it's moving message to specific channel. For example, if message reaction has "like_emoji", it has to move this message.content to "xxx" channel. I couldn't find any solution on stackoverflow (or maybe I didn't search deeper).
Here is my code:
import os
import sys
import discord
from discord.ext import commands
my_secret = os.environ['locksecret']
intents = discord.Intents.default()
intents = discord.Intents(messages=True,guilds=True,reactions=True,members=True,presences=True)
Bot = commands.Bot(command_prefix = "!",intents=intents)
@Bot.event
async def on_reaction_add(reaction,user):
channel = reaction.message.channel
await channel.send("emoji added")
if reaction.emoji == '👍':
channel = Bot.get_channel("channel_id")
await channel.send("{} written by:\n {}".format(message.author.mention,message.content))
await message.channel.send("{} your message move to this channel --> {}".format(message.author.mention,channel.mention))
await message.add_reaction("✔️")
Bot.run(my_secret)
When I do this, I get this error:
***Ignoring exception in on_reaction_add
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 57, in on_reaction_add
await channel.send("{} written by:\n {}".format(message.author.mention,message.content))
NameError: name 'message' is not defined***
How can I solve this problem? By the way, in code spaces, there is some code that I tried to bot command, because of this, console says "line 57"
message.author.mention, message.contentandmessage.channel.sendbutmessageis not defined in any way.