Discord.js Inbedded buttons not wokring

"TypeError: Cannot read properties of undefined (reading 'PRIMARY') at Object.execute (/Users/lex/TheHierarchysBot/Bot/commands/message/ticketinfo.js:20:42) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Client.<anonymous> (/Users/lex/TheHierarchysBot/Bot/index.js:101:9) " With this code "const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyles } = require('discord.js'); module.exports = { name: 'ticketinfo', description: 'Displays information about The Hierarchy Tickets.', async execute(interaction) { const roleID = '1156687225300467774'; const member = await interaction.guild.members.fetch(interaction.user.id); if (!member || !member.roles.cache.some(role => role.id === roleID)) { return await interaction.reply({ content: 'You do not have permission to use this command.', ephemeral: true }); } // Create the button const button = new ButtonBuilder() .setCustomId('create-ticket'); // Set the style of the button if (member.roles.cache.some(role => role.id === roleID)) { button.setStyle(ButtonStyles.PRIMARY); } else { button.setStyle(ButtonStyles.SECONDARY); } // Create the action row const row = new ActionRowBuilder() .addComponents(button); // Create the embed const embed = new EmbedBuilder() .setColor('#00FF00') // Sets the color to green .addFields( { name: 'Contact', value: To open a ticket, <@1156691598550249583>!, inline: false } ) .setFooter({ text: 'If you need additional support/tickets are not working, Dm the owner' }); // Send the reply await interaction.reply({ embeds: [embed], components: [row] }); }, }; " discord.js 14.13.0 newest node
2 Replies
d.js toolkit
d.js toolkitā€¢14mo 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!
Lex
LexOPā€¢14mo ago
well damn im dumb šŸ’€ "ValidationError > s.nativeEnum(T) Expected the value to be a string or number Received: | undefined at NativeEnumValidator.handle (/Users/lex/TheHierarchysBot/Bot/node_modules/@sapphire/shapeshift/dist/index.js:1871:25) at NativeEnumValidator.parse (/Users/lex/TheHierarchysBot/Bot/node_modules/@sapphire/shapeshift/dist/index.js:212:88) at ButtonBuilder.setStyle (/Users/lex/TheHierarchysBot/Bot/node_modules/@discordjs/builders/dist/index.js:636:44) at Object.execute (/Users/lex/TheHierarchysBot/Bot/commands/message/ticketinfo.js:20:20) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Client.<anonymous> (/Users/lex/TheHierarchysBot/Bot/index.js:101:9) " idek what this is goin on abt šŸ’€ Idk i did some changes that u said
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');

const PRIMARY = 'Primary';

module.exports = {
name: 'ticketinfo',
description: 'Displays information about The Hierarchy Tickets.',
async execute(interaction) {
const roleID = '1156687225300467774';
const member = await interaction.guild.members.fetch(interaction.user.id);

if (!member || !member.roles.cache.some(role => role.id === roleID)) {
return await interaction.reply({ content: 'You do not have permission to use this command.', ephemeral: true });
}

// Create the button
const button = new ButtonBuilder()
.setCustomId('create-ticket');

// Set the style of the button
if (member.roles.cache.some(role => role.id === roleID)) {
button.setStyle(ButtonStyle.PRIMARY);
} else {
button.setStyle(ButtonStyle.SECONDARY);
}

// Create the action row
const row = new ActionRowBuilder()
.addComponents(button);

// Create the embed
const embed = new EmbedBuilder()
.setColor('#00FF00') // Sets the color to green
.addFields(
{ name: '**Contact**', value: `To open a ticket, <@1156691598550249583>!`, inline: false }
)
.setFooter({ text: 'If you need additional support/tickets are not working, Dm the owner' });

// Send the reply
await interaction.reply({ embeds: [embed], components: [row] });
},
};
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');

const PRIMARY = 'Primary';

module.exports = {
name: 'ticketinfo',
description: 'Displays information about The Hierarchy Tickets.',
async execute(interaction) {
const roleID = '1156687225300467774';
const member = await interaction.guild.members.fetch(interaction.user.id);

if (!member || !member.roles.cache.some(role => role.id === roleID)) {
return await interaction.reply({ content: 'You do not have permission to use this command.', ephemeral: true });
}

// Create the button
const button = new ButtonBuilder()
.setCustomId('create-ticket');

// Set the style of the button
if (member.roles.cache.some(role => role.id === roleID)) {
button.setStyle(ButtonStyle.PRIMARY);
} else {
button.setStyle(ButtonStyle.SECONDARY);
}

// Create the action row
const row = new ActionRowBuilder()
.addComponents(button);

// Create the embed
const embed = new EmbedBuilder()
.setColor('#00FF00') // Sets the color to green
.addFields(
{ name: '**Contact**', value: `To open a ticket, <@1156691598550249583>!`, inline: false }
)
.setFooter({ text: 'If you need additional support/tickets are not working, Dm the owner' });

// Send the reply
await interaction.reply({ embeds: [embed], components: [row] });
},
};
`
Want results from more Discord servers?
Add your server