<@&undefined>

the collector:
collector.on('collect', i => {
if (i.user.id === interaction.user.id) {
if (msg.deletable) {
msg.delete().then(async () => {
const categoryValue = i.values[0]; // Get the selected category value
const categorySupportRoleId = client.config.categoryRoles[categoryValue]; // Get the corresponding support role ID for the selected category

let categorySupportRole;
try {
categorySupportRole = await interaction.guild.roles.fetch(categorySupportRoleId);
} catch (error) {
console.error(error);
}

console.log('Category Value:', categoryValue);
console.log('Category Support Role ID:', categorySupportRoleId);
console.log('Category Support Role:', categorySupportRole ? categorySupportRole.name : 'Not found');

// Check if the support role was found correctly
if (!categorySupportRole) {
return interaction.channel.send(`Support role for \`${categoryValue}\` not found! Please contact a server administrator.`);
}

const embed = new client.discord.MessageEmbed()
.setColor('6d6ee8')
.setAuthor({name: 'Ticket', iconURL: interaction.user.displayAvatarURL()})
.setDescription(`<@!${interaction.user.id}> Created a ticket with issues regarding \`${i.values[0]}\``)
.addFields(
{ name: '``/add [user]``', value: '**To add someone to the ticket**', inline: true },
{ name: '``/remove [user]``', value: '**To remove someone to the ticket**', inline: true },
)
.setTimestamp();

const row = new client.discord.MessageActionRow()
.addComponents(
new client.discord.MessageButton()
.setCustomId('close-ticket')
.setLabel('close')
.setEmoji('✖')
.setStyle('DANGER'),
);

const opened = await c.send({
content: `<@&${categorySupportRole.id}>`,
embeds: [embed],
components: [row]
});

opened.pin().then(() => {
opened.channel.bulkDelete(1);
});
});
};
};
});
collector.on('collect', i => {
if (i.user.id === interaction.user.id) {
if (msg.deletable) {
msg.delete().then(async () => {
const categoryValue = i.values[0]; // Get the selected category value
const categorySupportRoleId = client.config.categoryRoles[categoryValue]; // Get the corresponding support role ID for the selected category

let categorySupportRole;
try {
categorySupportRole = await interaction.guild.roles.fetch(categorySupportRoleId);
} catch (error) {
console.error(error);
}

console.log('Category Value:', categoryValue);
console.log('Category Support Role ID:', categorySupportRoleId);
console.log('Category Support Role:', categorySupportRole ? categorySupportRole.name : 'Not found');

// Check if the support role was found correctly
if (!categorySupportRole) {
return interaction.channel.send(`Support role for \`${categoryValue}\` not found! Please contact a server administrator.`);
}

const embed = new client.discord.MessageEmbed()
.setColor('6d6ee8')
.setAuthor({name: 'Ticket', iconURL: interaction.user.displayAvatarURL()})
.setDescription(`<@!${interaction.user.id}> Created a ticket with issues regarding \`${i.values[0]}\``)
.addFields(
{ name: '``/add [user]``', value: '**To add someone to the ticket**', inline: true },
{ name: '``/remove [user]``', value: '**To remove someone to the ticket**', inline: true },
)
.setTimestamp();

const row = new client.discord.MessageActionRow()
.addComponents(
new client.discord.MessageButton()
.setCustomId('close-ticket')
.setLabel('close')
.setEmoji('✖')
.setStyle('DANGER'),
);

const opened = await c.send({
content: `<@&${categorySupportRole.id}>`,
embeds: [embed],
components: [row]
});

opened.pin().then(() => {
opened.channel.bulkDelete(1);
});
});
};
};
});
config.json:
"categoryRoles": {
"Category1": "1133863974367146075",
"Category2": "1133871611360071730",
"Category3": "1133864161181446266"
},
"categoryRoles": {
"Category1": "1133863974367146075",
"Category2": "1133871611360071730",
"Category3": "1133864161181446266"
},
console.log:
Category Value: Player Lore Deployment
Category Support Role ID: undefined
Category Support Role: undefined
Category Value: Player Lore Deployment
Category Support Role ID: undefined
Category Support Role: undefined
2 Replies
d.js toolkit
d.js toolkit11mo 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!
Chayy
Chayy11mo ago
node v20.5.0 discord.js 13.15.1 its a ticket system, and i trying to each category have a different role mentioned nevermind fixed