const guild = interaction.guild; const user = interaction.user; const ticketChannelName =
票-${user.username}`
// 如果不退出则创建类别
const Category = guild.channels.cache.find(c => c.name == 'TICKETS' && c.type == ChannelType.GuildCategory);
控制台.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: [embed], 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.
});
}
}
}`
我想在类别内创建一个频道,但我不能,频道正在创建,但不在类别内。
尝试输入类别频道 ID 而不是常量变量。
await interaction.guild.channels.create({
parent: category.id, //here
name: ticketChannelName,
type: ChannelType.GuildText,
});