const guild = interaction.guild; const user = interaction.user; const ticketChannelName =
ticket-${user.username}`
// create category if not exits
const category = guild.channels.cache.find(c => c.name == ‘TICKETS’ && c.type == ChannelType.GuildCategory);
console.log()
if(!category) {
await interaction.guild.channels.create({
name: 'TICKETS', // The name given to the Channel by the user
type: ChannelType.GuildCategory, // The type of the Channel created.
deny: ['VIEW_CHANNEL'], // The permissions of the Channel created.
});
}
else{
}
const channel = guild.channels.cache.find(c => c.name == {ticketChannelName} && c.type == ChannelType.GuildText);
if(channel) {
const embed = new EmbedBuilder()
.setTitle('Hata!')
.setDescription('Zaten bir ticket oluşturmuşsunuz.')
.setColor(Colors.Red)
.setTimestamp();
return await interaction.reply({embeds: , ephemeral: true});
}
else{
await interaction.guild.channels.create({
parent: category, // The category of the Channel created.
name: ticketChannelName, // The name given to the Channel by the user
type: ChannelType.GuildText, // The type of the Channel created.
});
}
}
}`
I want to create a channel within category but i cant, the channel is creating but not within category.
2
Answers
Try putting category channel id instead of constant variable.
You can check out the guide in the official discord.js docs categoryObject.parent