So im confused on how to make my discord bot make a new like text channel called general 2 when i do !setup, the command works perfectly fine but i dont know how to make it make a new channel, please help.
require('dotenv').config()
const { Client, IntentsBitField, StringSelectMenuBuilder,StringSelectMenuOptionBuilder, SlashCommandBuilder,ChannelType, Guild} = require('discord.js')
const client = new Client ({
intents : [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
]
})
client.on('ready', (c) => {
console.log('Server Setup is ready')
})
//What i've tried
client.on('messageCreate', (message) =>{
if (message.content === '!setup') {
var server = message.guild;
var name = message.author.username;
server.channels.create(name,"text")
}
})
client.login(
process.env.Token
)
I tried watching some youtube tutorials, it ended up either causing errors or doing nothing. It kept on making this error :
DiscordAPIError[50035]: Invalid Form Body
name[BASE_TYPE_REQUIRED]: This field is required
Nathan Liwang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.