Python Bot use custom Emoji

Demotry picture Demotry · Aug 23, 2018 · Viewed 14.9k times · Source

How to make my bot use my custom emoji in any discord server.

@bot.command(pass_context=True)
async def ping(ctx):
    msg = "Pong :CustomEmoji: {0.author.mention}".format(ctx.message)
    await bot.say(msg)

Example: If I upload some custom emojis on server 1 and when we use the !ping command (mentioned above) in server 2 or server 3 or any server where the bot has access to, it should use the custom emoji. Result Pong with :CustomEmoji:

Answer

Moorhuhn picture Moorhuhn · Aug 23, 2018

From https://github.com/Rapptz/discord.py/issues/390:

It's <:emoji_name:emoji_id> for custom emojis.

You can also find the discord.Emoji instance through Server.emojis and then cast it to str.