I'm confused on how to make my Discord bot make a new text channel called 'General 2'. When I do !setup
the command works perfectly fine but I don't know how to make it make a new channel.
I tried some Youtube tutorials, but 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
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)
.create
needs only 1 object
argument.
server.channels.create({ name })