Setting emojis in a select menu

select.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel(`${result.label}`)
.setDescription('test')
.setEmoji(/* What do I put here? */)
.setDescription('x')
.setValue(result.label)
);
select.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel(`${result.label}`)
.setDescription('test')
.setEmoji(/* What do I put here? */)
.setDescription('x')
.setValue(result.label)
);
What exactly do I put in setEmoji? Every time I try and run the bot, it crashes with
{
code: "BUTTON_COMPONENT_INVALID_EMOJI",
message: "Invalid emoji",
}
{
code: "BUTTON_COMPONENT_INVALID_EMOJI",
message: "Invalid emoji",
}
Using 👍 as the example I've tried (and can't remember the rest): - "thumbups" - { name: "thumbups"} - "<:thumbups:>" - interaction.client.emojis.cache.get("thumbsup")
41 Replies
d.js toolkit
d.js toolkit4mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Jake
JakeOP4mo ago
It's being pulled from a database which I don't think can store the unicode.
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Jake
JakeOP4mo ago
Just as the emoji name itself. so 👍 would be stored as 'thumbsup'
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs4mo ago
:function: parseEmoji @14.15.3 Parses emoji info out of a string. The string must be one of:* A UTF-8 emoji (no id)* A URL-encoded UTF-8 emoji (no id)* A Discord custom emoji (<:name:id> or <a:name:id>)
Jake
JakeOP4mo ago
k gimme a second... Still getting invalid emoji. does it need the colons as well or just the name?
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Jake
JakeOP4mo ago
k 1 sec
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Jake
JakeOP4mo ago
sqlite emojis come back as
eagle
flag_eu
earth_asia
earth_africa
ocean
flag_br
eagle
flag_eu
earth_asia
earth_africa
ocean
flag_br
thats using console.log
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Jake
JakeOP4mo ago
Unless there's something wrong with the emoji it's returning? just jumped in a watch window to check what parseEmoji returns and I get this
{
id: undefined,
name: "eagle",
animated: false,
}
{
id: undefined,
name: "eagle",
animated: false,
}
It's not the undefined value causing the problem is it?
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Jake
JakeOP4mo ago
yeah it's just the word.
Jake
JakeOP4mo ago
Not sure if this'll help, but lemme grab that bit of code for you.
No description
Jake
JakeOP4mo ago
const emojis = category.emojis.map(emoji => {
return {
name: emoji[0],
label: emoji[1],
role_id: emoji[2]
}
});
await database.models.category.create({
name: category.category,
emojis: emojis
},
{
include: database.models.emoji,
transaction: transaction
});
const emojis = category.emojis.map(emoji => {
return {
name: emoji[0],
label: emoji[1],
role_id: emoji[2]
}
});
await database.models.category.create({
name: category.category,
emojis: emojis
},
{
include: database.models.emoji,
transaction: transaction
});
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Jake
JakeOP4mo ago
The array looks like this: ["eagle", "North America", "1040332478910570582"]
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs4mo ago
:typealias: EmojiResolvable @14.15.3 Data that can be resolved into a GuildEmoji object. This can be:* A Snowflake* A GuildEmoji object* A ReactionEmoji object
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs4mo ago
:typealias: ComponentEmojiResolvable @14.15.3 Any emoji data that can be used within a button
Jake
JakeOP4mo ago
Yeah I found that before, just trying to figure out to how to use it in code.
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Jake
JakeOP4mo ago
dont think sqlite supports it tbh trying a few other things atm, bear with me Nah it's still complaining about an invalid form body. It doesn't like that emoji for whatever reason.
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Jake
JakeOP4mo ago
no it's failing on any emoji
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Jake
JakeOP4mo ago
Haven't got any to test, and I can't set them on the server in question.
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Jake
JakeOP4mo ago
one more dumb thing to try, sec right, im confused
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Jake
JakeOP4mo ago
if i copy 🦅 into my code, it pastes as :eagle:, so... wtf
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Jake
JakeOP4mo ago
k, got it pasted, sec that works, so... i have no idea
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Jake
JakeOP4mo ago
And there's no way to convert the plain text name to the emoji?
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Jake
JakeOP4mo ago
Someones about to get told to get a new plan or do it themselves them. No worries.
Want results from more Discord servers?
Add your server