fetch the new created channel

const { SlashCommandBuilder,PermissionFlagsBits } = require('discord.js');

module.exports = {
    data: new SlashCommandBuilder()
        .setName('create')
        .setDescription('add'),
    async execute(interaction) {
        interaction.guild.channels.create({ 
            name: 'testticket',
            reason: 'ticket',
            permissionOverwrites: [
                {
                    id: interaction.guild.roles.everyone,
                    deny: [PermissionFlagsBits.ViewChannel],
                },
            ],
        });
        channels.fetch();
        const newchannel = channel.id;
        await interaction.reply(` ${interaction.user.username} created a ticket at${newchannel}`);
    },
};
Was this page helpful?