首页 > 解决方案 > 通过 dms discord.py 发送动画表情符号

问题描述

我见过很多不和谐的机器人使用动画表情符号来攻击我。我了解如何在服务器中发送动画表情符号,因为表情符号在服务器中。但是他们怎么能用动画表情符号给我发短信呢?我想在用户进行验证时发送 dm,机器人回复 dm 说:“您已通过验证!” 带有表情符号。

@bot.command()
async def verify(ctx):
    helpembed=discord.Embed(title="Verification", url=" ", description="You have been verified!", color=discord.Color.blue())
    await ctx.author.send(embed=helpembed)

标签: pythondiscorddiscord.py

解决方案


Discord 对自定义和动画表情符号使用特殊模式(就像它对频道提及和用户提及所做的那样)。

animated_emoji = "<a:emoji_name:emoji_id>"
custom_emoji = "<:emoji_name:emoji_id>"

如果您有表情符号 ID,这将适用于自定义和动画表情符号:( client.get_emoji )

emoji = bot.get_emoji(emoji_id)
await ctx.send("Hello! {}".format(emoji))

如果你有它的名字公会表情符号来自:(utils.getguild.emojis

from discord import utils

emoji = utils.get(guild.emojis, name="my emoji name")
await ctx.send("Hello! {}".format(emoji))

参考:


推荐阅读