Emojies not working with select

const { ActionRowBuilder, StringSelectMenuBuilder, StringSelectMenuInteraction, InteractionType } = require('discord.js');
const config = require('../../../ticketConfig.json');

module.exports = async (client, interaction) => {

console.log("Interaction received:", interaction);

if (interaction.type !== InteractionType.MessageComponent) {
console.log("Interaction is not of type MessageComponent.");
return;
}

if (!(interaction instanceof StringSelectMenuInteraction)) {
console.log("Interaction is not an instance of StringSelectMenuInteraction.");
return;
}

if (!interaction.customId.startsWith('select_category_')) {
console.log("customId does not start with 'select_category_'.");
return;
}

const selectedCategory = config.categories.find(category => category.name.toLowerCase() === interaction.values[0]);
if (!selectedCategory) {
console.log("Selected category not found.");
return;
}

const categoryEmoji = selectedCategory.emoji
? parseEmoji(selectedCategory.emoji)
: undefined;

const items = selectedCategory.items.map(item => {
return {
label: item.name,
value: item.id
};
});

console.log("Mapped items:", items);
console.log("Category emoji:", categoryEmoji);

try {
const itemMenu = new StringSelectMenuBuilder()
.setCustomId(`select_item_${selectedCategory.name.toLowerCase()}`)
.setPlaceholder('Select an item')
.addOptions(items);

const row = new ActionRowBuilder().addComponents(itemMenu);

await interaction.update({
content: `Please select an item from **${selectedCategory.name}** ${categoryEmoji ? `<:${categoryEmoji.name}:${categoryEmoji.id}>` : ''}:`,
components: [row],
ephemeral: true
});
} catch (err) {
console.log("Error during menu creation or interaction update:", err);
}
};

function parseEmoji(emojiString) {
const [name, id] = emojiString.split(':');
return { name, id };
}
const { ActionRowBuilder, StringSelectMenuBuilder, StringSelectMenuInteraction, InteractionType } = require('discord.js');
const config = require('../../../ticketConfig.json');

module.exports = async (client, interaction) => {

console.log("Interaction received:", interaction);

if (interaction.type !== InteractionType.MessageComponent) {
console.log("Interaction is not of type MessageComponent.");
return;
}

if (!(interaction instanceof StringSelectMenuInteraction)) {
console.log("Interaction is not an instance of StringSelectMenuInteraction.");
return;
}

if (!interaction.customId.startsWith('select_category_')) {
console.log("customId does not start with 'select_category_'.");
return;
}

const selectedCategory = config.categories.find(category => category.name.toLowerCase() === interaction.values[0]);
if (!selectedCategory) {
console.log("Selected category not found.");
return;
}

const categoryEmoji = selectedCategory.emoji
? parseEmoji(selectedCategory.emoji)
: undefined;

const items = selectedCategory.items.map(item => {
return {
label: item.name,
value: item.id
};
});

console.log("Mapped items:", items);
console.log("Category emoji:", categoryEmoji);

try {
const itemMenu = new StringSelectMenuBuilder()
.setCustomId(`select_item_${selectedCategory.name.toLowerCase()}`)
.setPlaceholder('Select an item')
.addOptions(items);

const row = new ActionRowBuilder().addComponents(itemMenu);

await interaction.update({
content: `Please select an item from **${selectedCategory.name}** ${categoryEmoji ? `<:${categoryEmoji.name}:${categoryEmoji.id}>` : ''}:`,
components: [row],
ephemeral: true
});
} catch (err) {
console.log("Error during menu creation or interaction update:", err);
}
};

function parseEmoji(emojiString) {
const [name, id] = emojiString.split(':');
return { name, id };
}
6 Replies
d.js toolkit
d.js toolkit5mo 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!
treble/luna
treble/luna5mo ago
and what exactly isnt working
GustyCube
GustyCubeOP5mo ago
No emoji In menu
treble/luna
treble/luna5mo ago
Well i dont see you setting any You're only setting a label and value
GustyCube
GustyCubeOP5mo ago
Right. How would I add the emoji? I’m not sure if there’s a special way to add the ids for that or whaterver
d.js docs
d.js docs5mo ago
:propertysignature: SelectMenuComponentOptionData#emoji @14.15.3 The emoji on the option
Want results from more Discord servers?
Add your server