I want to forward messages sent on a particular channel to another channel based on number of reactions on ???? emoji reaction. The message has a few embeds and is being sent by the YAGPDB.xyz bot from a sub reddit. If the message in a particular channel gets more than one down vote reaction I want to forward that message to another channel and delete it on the current channel. Here's what a typical message from this bot looks like(with embeds),
I have written the following code,
@client.event
async def on_raw_reaction_add(payload):
if payload.channel_id in CHANNEL_LIST:
if payload.emoji.name=='\U0001F53C':
channel=client.get_channel(payload.channel_id)
message=await channel.fetch_message(payload.message_id)
reaction=get(message.reactions,emoji=payload.emoji.name)
if reaction and reaction.count>1:
await message.pin()
elif payload.emoji.name=='\U0001F53B':
channel=client.get_channel(payload.channel_id)
message=await channel.fetch_message(payload.message_id)
reaction=get(message.reactions,emoji=payload.emoji.name)
if reaction and reaction.count>1:
channel=client.get_channel(DELETED_MESSAGES_CHANNEL)
await channel.send('{}: {}'.format(message.author, message.content),embed=message.content.embeds)
await message.delete()
I get the following error,
Ignoring exception in on_raw_reaction_add
Traceback (most recent call last):
File "C:\Python\Python38\lib\site-packages\discord\client.py", line 312, in _run_event
await coro(*args, **kwargs)
File "s.py", line 46, in on_raw_reaction_add
await channel.send('{}: {}'.format(message.author, message.content),embed=message.content.embeds)
AttributeError: 'str' object has no attribute 'embeds'
If I use embed=message.embeds
instead of message.content.embeds
, i get the following error,
Ignoring exception in on_raw_reaction_add
Traceback (most recent call last):
File "C:\Python\Python38\lib\site-packages\discord\client.py", line 312, in _run_event
await coro(*args, **kwargs)
File "s.py", line 46, in on_raw_reaction_add
await channel.send('{}: {}'.format(message.author, message.content),embed=message.embeds)
File "C:\Python\Python38\lib\site-packages\discord\abc.py", line 828, in send
embed = embed.to_dict()
AttributeError: 'list' object has no attribute 'to_dict'
How do I get all the embeds in this message and forward it as it was sent here to another channel? And also, how do I get to know the number of members in my server who are NOT BOTS? Any suggestions are much appreciated!
embed=message.embeds
? Pretty sure thatembeds
is at the same level ascontent
, not a subordinate. – DaveStSomeWhere