Discord.py获取消息链接

2024-07-03 07:08:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经为我的discord.py bot制作了一个右舷,现在我想添加一个“跳转到内容”行,它重定向到消息,下面是我当前的代码:

@client.event
async def on_reaction_add(reaction, member):
    schannel = client.get_channel(channel_id)
    
    if (reaction.emoji == '⭐') and (reaction.count >= 3):
        embed = discord.Embed(color = 15105570)
        embed.set_author(name = reaction.message.author.name, icon_url = reaction.message.author.avatar_url)
        embed.add_field(name = "Message Content", value = reaction.message.content)
        
        if len(reaction.message.attachments) > 0:
            embed.set_image(url = reaction.message.attachments[0].url)
        
        embed.set_footer(text = f" ⭐ {reaction.count} | # {reaction.message.channel.name}")
        embed.timestamp = datetime.datetime.utcnow()
        await schannel.send(embed = embed)

请帮助我,提前谢谢:)


Tags: nameclientaddurlmessageifcountchannel