using emoji from different server, nextcord bot

Viewed 332

I'm trying to get emoji's from a another server. I creates a server object for the server, it is a constant because I want to only pull from this server.

for emoji in main_tuple:
       emoji_name_id =await server.fetch_emoji(emoji)
       emoji_array.append(f"<{emoji_name_id.name.lower()}:{emoji_name_id.id}>")

error:

nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: NotFound: 404 Not Found (error code: 10014): Unknown Emoji

I should mention I want to display it another server, I know this is probably obvious but yeah. main_tuple is a directionary in a database that has the emoji id and name. the error

Also the bot is part of the server it's getting the id from. I have looked at: discord.py emoji all servers bot in and it does not work for me.

1 Answers

First Issue, you are making a wrong reference. <:Name:ID> and not <Name:ID> (if you don't see it, you missed the first colon)

Another issue,

emoji_name_id.name.lower()

Custom emojis are to have to have 'exact' name and ID as they have, by using lower method, you would be trying to reference a wrong custom emote. For example:

The actual emote which might have the following reference <:ThisIsACoolEmote:ID>, while you are appending <:thisisacoolemote:ID> which doesn't exist

To mitigate this, you can just append str(emoji_name_id) which will automatically give you the correct emote reference which is in the format <:Name:ID:> and yes, it also will format animated emojis too, i.e:<a:Name:ID>

also fetching here might not be the best practice, you can use bot.get_emoji instead which gets emote from internal cache if you have access to member Privileged Intent.

Related