Discord Bot 嵌入自定义表情符号
Discord Bot Embed Custom Emoji
我正在创建一个 python discord 机器人,它将以嵌入格式输出消息。
我已将一些自定义表情符号添加到 discord 服务器,并想在嵌入消息中使用它们。
我希望它看起来像这样 https://imgur.com/a/ezUJXoQ 除了使用的表情符号将是自定义表情符号而不是 discord 默认表情符号。
我还希望表情符号位于 'description' 字段中。自定义表情符号在标题中工作正常,但在 'description' 中不起作用。
embed = discord.Embed(title="Here is the **title**! <:emoji1:52342365738338334>", color=0x24045b, description="Here is the emoji again! <:emoji1:52342365738338334>"
最简单的方法是获取代表自定义表情符号的 Emoji
对象,然后使用它来构建字符串
from discord.utils import get
@bot.command(pass_context=True)
async def respond(ctx):
emoji = get(ctx.message.server.emojis, name="emoji1")
embed = Embed(title=f"Here is the **title**! {emoji}", color=0x24045b, description=f"Here is the emoji again! {emoji}")
await bot.say(embed=embed)
这是一个调试命令,您可以使用它来获取有关表情符号的信息
from discord import Embed, Emoji
from discord.ext.commands import Bot
bot = Bot(command_prefix='!')
@bot.command(pass_context=True)
async def debug(ctx, emoji: Emoji):
embed = Embed(description=f"emoji: {emoji}", title=f"emoji: {emoji}")
embed.add_field(name="id", value=repr(emoji.id))
embed.add_field(name="name", value=repr(emoji.name))
await bot.say(embed=embed)
bot.run("token")
从 !debug :emojiname:
的 discord 中调用它,它应该会为您提供有关该表情符号的信息。如果没有,那么您可能正在尝试使用不存在的表情符号,或者您的机器人看不到(通常表情符号必须来自服务器调用命令 in/the 响应是被发布到)
我正在创建一个 python discord 机器人,它将以嵌入格式输出消息。
我已将一些自定义表情符号添加到 discord 服务器,并想在嵌入消息中使用它们。
我希望它看起来像这样 https://imgur.com/a/ezUJXoQ 除了使用的表情符号将是自定义表情符号而不是 discord 默认表情符号。
我还希望表情符号位于 'description' 字段中。自定义表情符号在标题中工作正常,但在 'description' 中不起作用。
embed = discord.Embed(title="Here is the **title**! <:emoji1:52342365738338334>", color=0x24045b, description="Here is the emoji again! <:emoji1:52342365738338334>"
最简单的方法是获取代表自定义表情符号的 Emoji
对象,然后使用它来构建字符串
from discord.utils import get
@bot.command(pass_context=True)
async def respond(ctx):
emoji = get(ctx.message.server.emojis, name="emoji1")
embed = Embed(title=f"Here is the **title**! {emoji}", color=0x24045b, description=f"Here is the emoji again! {emoji}")
await bot.say(embed=embed)
这是一个调试命令,您可以使用它来获取有关表情符号的信息
from discord import Embed, Emoji
from discord.ext.commands import Bot
bot = Bot(command_prefix='!')
@bot.command(pass_context=True)
async def debug(ctx, emoji: Emoji):
embed = Embed(description=f"emoji: {emoji}", title=f"emoji: {emoji}")
embed.add_field(name="id", value=repr(emoji.id))
embed.add_field(name="name", value=repr(emoji.name))
await bot.say(embed=embed)
bot.run("token")
从 !debug :emojiname:
的 discord 中调用它,它应该会为您提供有关该表情符号的信息。如果没有,那么您可能正在尝试使用不存在的表情符号,或者您的机器人看不到(通常表情符号必须来自服务器调用命令 in/the 响应是被发布到)