Skip to content
Advertisement

discord.py emoji all servers bot in

I have a bot that sends embeds that include emojis specific to each embed and it works great on my test server where I uploaded the emojis but they don’t show up on other servers since those servers don’t have the custom emoji.

using:

emoji = get(ctx.message.guild.emojis, name='emojinamehere')

works of course for the server it’s in but is there a way to get and use all emojis from any servers the bot is in?

Advertisement

Answer

Because you’re specifically using ctx.message.guild.emojis aka you’re trying to get the emoji from the context guild (which might not have it).

You can get rid of get finding by name and just use bot.get_emoji() where bot is your bot/client object.

Your bot will store all emojis from all the guilds in internal cache and get_emoji() will retrieve it from there so it will work for all guilds.

You will need emoji ID (integer) to do this, not name as you’re currently getting. You could get by name and then get its ID but that’s just unnecessary steps.

Just use emoji ID as those are unique and can’t change (names can both be duplicate and can change so you can get into problems getting by name).

You can quickly get emoji ID by using Discord client app:

  • enter custom emoji in the text box input
  • enter before emoji
  • send message to chat
  • message will transfom into somemthing like <:emoji_name:emoji_id>
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement