#Emojis is not working

34 messages · Page 1 of 1 (latest)

gritty monolith
#

Hello, custom emojis don't work.

pale owlBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

gritty monolith
#
const test = new ActionRowBuilder()
            .addComponents(
                new ButtonBuilder()
                    .setCustomId(`Test`)
                    .setLabel(`Test`)
                    .setStyle(ButtonStyle.Success)
                    .setEmoji(Guild.emojis.cache.find(emoji => emoji.name === 'TestEmoji' )),
            );
fierce elk
gritty monolith
#

?

gritty monolith
#
TypeError: Cannot read properties of undefined (reading 'cache')
    at Object.execute (/Volumes/Transcend/Bot Discord/Aiwoz/commands/roles.js:22:29)
    at Client.<anonymous> (/Volumes/Transcend/Bot Discord/Aiwoz/index.js:50:17)
    at Client.emit (/Volumes/Transcend/Bot Discord/Aiwoz/lib/events.js:525:35)
    at InteractionCreateAction.handle (/Volumes/Transcend/Bot Discord/Aiwoz/node_modules/discord.js/src/client/actions/InteractionCreate.js:81:12)
    at module.exports [as INTERACTION_CREATE] (/Volumes/Transcend/Bot Discord/Aiwoz/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
    at WebSocketManager.handlePacket (/Volumes/Transcend/Bot Discord/Aiwoz/node_modules/discord.js/src/client/websocket/WebSocketManager.js:352:31)
    at WebSocketShard.onPacket (/Volumes/Transcend/Bot Discord/Aiwoz/node_modules/discord.js/src/client/websocket/WebSocketShard.js:481:22)
    at WebSocketShard.onMessage (/Volumes/Transcend/Bot Discord/Aiwoz/node_modules/discord.js/src/client/websocket/WebSocketShard.js:321:10)
    at WebSocket.onMessage (/Volumes/Transcend/Bot Discord/Aiwoz/node_modules/ws/lib/event-target.js:199:18)
    at WebSocket.emit (node:events:513:28) {stack: 'TypeError: Cannot read properties of undefine…8)
    at WebSocket.emit (node:events:513:28)', message: 'Cannot read properties of undefined (reading 'cache')'}
gritty monolith
small prairie
gritty monolith
gritty monolith
#

const server = new Guild();

#

Is correct ?

fierce elk
#

Pretty sure you want a specific guild, not a new guild without any information in it. What guild are the emojis you want to use on?

gritty monolith
#

On my server.

#

the bot too

fierce elk
#

So it would probably be the interaction.guild in your context then. That is a Guild instance

gritty monolith
#

cache is not defined

fierce elk
#

Show the actual error with its stack

gritty monolith
#

I hava a other error.

const { SlashCommandBuilder, PermissionsBitField, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, Guild } = require(`discord.js`);

module.exports = {
    data: new SlashCommandBuilder()
        .setName(`roles`)
        .setDescription(`Permet d'envoyer les boutons des rôles.`),
    async execute(interaction) {
        if(interaction.member?.permissions.has(PermissionsBitField.Flags.Administrator)) {
            const memberInteraction = interaction.member;

            const roles1 = new EmbedBuilder()
            .setTitle(`Rôles : Langages de programmation.`)
            .setColor(0x7AF6CA)
            .setDescription(`Sélectionnez les langages de programmation que vous utilisez.`);
            
            const Testing = new ActionRowBuilder()
            .addComponents(
                new ButtonBuilder()
                    .setCustomId(`Test2`)
                    .setLabel(`TEST3`)
                    .setStyle(ButtonStyle.Success)
                    .setEmoji(interaction.guild.emojis.cache.find(emoji => emoji.name === 'Java' )),
            );
           
           
           
            interaction.channel.send({ embeds: [roles1], components: [Testing]});
            interaction.reply({content: `L'embed des rôles a bien été envoyé.`, ephemeral: true});
            console.log(memberInteraction.displayName + ` (` + memberInteraction + `) ` + `a envoyé les boutons des rôles du serveur.`);
        } else {
            interaction.reply(`Vous n'avez pas la permission pour envoyer les informations des rôles.`)
        }
    }
}
#

/usr/local/bin/node ./index.js
Logged in as Assistant - Aiwoz#4796!
Error: Received one or more errors
at ObjectValidator.handleStrictStrategy (/Volumes/Transcend/Bot Discord/Aiwoz/node_modules/@sapphire/shapeshift/dist/index.js:1279:70)
at ObjectValidator.handleStrategy (/Volumes/Transcend/Bot Discord/Aiwoz/node_modules/@sapphire/shapeshift/dist/index.js:1105:47)
at ObjectValidator.handle (/Volumes/Transcend/Bot Discord/Aiwoz/node_modules/@sapphire/shapeshift/dist/index.js:1193:17)
at ObjectValidator.parse (/Volumes/Transcend/Bot Discord/Aiwoz/node_modules/@sapphire/shapeshift/dist/index.js:142:88)
at ButtonBuilder.setEmoji (/Volumes/Transcend/Bot Discord/Aiwoz/node_modules/@discordjs/builders/dist/components/button/Button.cjs:26:49)
at ButtonBuilder.setEmoji (/Volumes/Transcend/Bot Discord/Aiwoz/node_modules/discord.js/src/structures/ButtonBuilder.js:25:18)
at Object.execute (/Volumes/Transcend/Bot Discord/Aiwoz/commands/roles.js:22:7)
at Client.<anonymous> (/Volumes/Transcend/Bot Discord/Aiwoz/index.js:50:17)
at Client.emit (/Volumes/Transcend/Bot Discord/Aiwoz/lib/events.js:525:35)
at InteractionCreateAction.handle (/Volumes/Transcend/Bot Discord/Aiwoz/node_modules/discord.js/src/client/actions/InteractionCreate.js:81:12) {errors: Array(6), stack: 'Error: Received one or more errors
at Obj…rc/client/actions/InteractionCreate.js:81:12)', message: 'Received one or more errors'}

fierce elk
#

Emoji probably isn’t in cache then. Fetch them before

gritty monolith
#

How ?

gritty monolith
#

?

pale owlBOT
#

Documentation suggestion for @gritty monolith:
method GuildEmojiManager#fetch()
Obtains one or more emojis from Discord, or the emoji cache if they're already available.

gritty monolith
#

Sorry, i am in the bus. (Belgium)

#

I will stay tonight

#

Thank you.

#

👍

gritty monolith
#

How to get emoji id ?

gritty monolith
#

Thank you. 😉