首页 > 解决方案 > 如何将自定义表情符号添加到嵌入式消息中?

问题描述

我做了什么:

我试图在我的嵌入中添加自定义表情符号。然而,这并没有成功。也许我正在使用过时的代码?我不确定究竟是什么导致它不起作用。我没有从控制台得到任何反馈,我的所有其他命令都有效。

@bot.command()
async def react(ctx):
    channel = bot.get_channel(865698553737117696)
    firework = get(ctx.message.server.emojis, name="firework")
    phone = get(ctx.message.server.emojis, name= "socials")
    react = discord.Embed(title = 'Reaction Roles:',description = 'Below are a range of reaction roles that allows you to be pinged when we announce something exciting:\n',colour = 0xE23D6E)

    react.set_author(name='Disney Dreams', icon_url= 'https://cdn.discordapp.com/attachments/809937571793993730/866327668970881034/logogoosggs.png')
    react.add_field(name='**Shows**', value=f'{firework}' + ': Allows you to get pinged when we make an announcement relating to shows here at Disney Dreams', inline= False)
    react.add_field(name='**Social Media**',
    value=f'{phone}' + ': Allows you to get pinged when we make a post on one of our social media pages', inline=False)

    reactions = await channel.send(embed=react)

    await reactions.add_reaction(':firework:')
    await reactions.add_reaction(':socials:')

标签: pythonpython-3.xdiscorddiscord.py

解决方案


是的,你用来获取表情符号的方式已经过时了。要做到这一点非常简单。

<a:emojiname:emojiid>

您可以替换emojiname为表情符号的名称和emojiid表情符号 ID。您只需<a:emojiname:emojiid>输入不和谐频道即可轻松获得\emoji,该消息会将其格式化为您需要的格式。当然emoji\emoji用实际的表情符号代替。

<a:emojiname:emojiid>用于动画表情符号

要用于普通表情符号或静态表情符号,请使用<:emojiname:emojiid>


推荐阅读