Chayy
DIAdiscord.js - Imagine an app
•Created by Chayy on 7/26/2023 in #djs-questions
<@&undefined>
the collector:
config.json:
console.log:
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);
});
});
};
};
});
"categoryRoles": {
"Category1": "1133863974367146075",
"Category2": "1133871611360071730",
"Category3": "1133864161181446266"
},
"categoryRoles": {
"Category1": "1133863974367146075",
"Category2": "1133871611360071730",
"Category3": "1133864161181446266"
},
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
6 replies