#Emojis is not working
34 messages · Page 1 of 1 (latest)
• 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.
const test = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`Test`)
.setLabel(`Test`)
.setStyle(ButtonStyle.Success)
.setEmoji(Guild.emojis.cache.find(emoji => emoji.name === 'TestEmoji' )),
);
Second and fourth bulletpoint. Read them and act accordingly
?
Read this
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')'}
How did you define Guild?
TEST 1 : const { Guild } = require(discord.js);
TEST 2 : interaction.guil.XXX
TEST 1: It should be an instance of the class, not the class itself.
TEST 2: interaction.guil__d__.XXX
TEST 2 : Sorry, error of keyboard
- How ?
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?
So it would probably be the interaction.guild in your context then. That is a Guild instance
yes but .setEmoji(interaction.guild.emojis.cache.find(emoji => emoji.name === 'TestEmoji' )),
cache is not defined
Show the actual error with its stack
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'}
Emoji probably isn’t in cache then. Fetch them before
?
Documentation suggestion for @gritty monolith:
GuildEmojiManager#fetch()
Obtains one or more emojis from Discord, or the emoji cache if they're already available.
How to get emoji id ?
Thank you. 😉