【发布时间】:2020-08-08 00:32:18
【问题描述】:
我想根据 ???? 上的反应数量将在特定频道上发送的消息转发到另一个频道表情符号反应。该消息有一些嵌入,并由 YAGPDB.xyz 机器人从子 reddit 发送。如果特定频道中的消息得到多个反对票反应,我想将该消息转发到另一个频道并在当前频道上删除它。这是来自这个机器人的典型消息的样子(带有嵌入),
@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()
我收到以下错误,
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'
如果我使用embed=message.embeds 而不是message.content.embeds,我会收到以下错误,
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'
如何获取此消息中的所有嵌入内容并将其转发到此处发送到另一个频道?还有,我如何知道我的服务器中不是机器人的成员数量?任何建议都非常感谢!
【问题讨论】:
-
你试过只使用
embed=message.embeds吗?很确定embeds和content处于同一级别,而不是下属。 -
@DaveStSomeWhere 是的,我已经尝试过了,并编辑了问题以将其输出包含在结尾。
标签: python discord embed discord.py forward