How to create a channel ?

I wrote some codes but it always shows
Cannot read properties of undefined (reading 'guilds')
Cannot read properties of undefined (reading 'guilds')
But i defined it at first.like
const { SlashCommandBuilder,PermissionFlagsBits } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('create')
.setDescription('add'),
async execute(interaction,client) {
const { guildId } = require('../../config/main/config.json');
client.guilds.cache
.get(guildId)
.channels.create({
name: 'testticket',
reason: 'ticket',
permissionOverwrites: [
{
id: interaction.guild.roles.everyone,
deny: [PermissionFlagsBits.ViewChannel],
},
],
})
.fetch();
const newchannel = channel.id;
await interaction.reply(` ${interaction.user.username} created a ticket at<#${newchannel}>`);
},
};
const { SlashCommandBuilder,PermissionFlagsBits } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('create')
.setDescription('add'),
async execute(interaction,client) {
const { guildId } = require('../../config/main/config.json');
client.guilds.cache
.get(guildId)
.channels.create({
name: 'testticket',
reason: 'ticket',
permissionOverwrites: [
{
id: interaction.guild.roles.everyone,
deny: [PermissionFlagsBits.ViewChannel],
},
],
})
.fetch();
const newchannel = channel.id;
await interaction.reply(` ${interaction.user.username} created a ticket at<#${newchannel}>`);
},
};
2 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Unicorn.
Unicorn.OP2y ago
thanks ❤️
Want results from more Discord servers?
Add your server