我想根据某个频道上的反应数量,将某个频道上发送的消息转发到另一个频道🔻 表情反应。该消息有一些嵌入,由YAGPDB.xyz bot从子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'
如何获取此消息中的所有嵌入信息,并将其发送到另一个通道?还有,我如何知道我的服务器中不是机器人的成员的数量?任何建议都将不胜感激
await channel.send('{}: {}'.format(message.author,message.content),embed=message.embeds[0])
通常,嵌入列表对象中只有一个嵌入。因此,在大多数情况下,只需使用嵌入[0]。到目前为止,我还没有看到包含多个嵌入的消息相关问题 更多 >
编程相关推荐