createChannel
Creates a new channel in the current guild.
Syntax
createChannel(name, type)
Parameters
name
: The name of the channel.type
: The type of the channel to create. Value must be either text or voice.
Permissions
Required permission which the bot must have for this function to work properly:
managechannels
Example
try {
const
msg = message.replace(commandPrefix, '').trim().replace(/ +/g, ' ').split(' '),
type = msg.shift().toLowerCase();
if (!type) {
setResponse(`Usage : \` ${commandPrefix} [Type] [Name] \``);
} else {
if (type === 'text' || type === 'voice') {
if (!msg.join(' '))
throw new Error('Provide a channel name!');
if (msg.join(' ').length > 100)
throw new Error('Couldn\'t create channel! Channel name must be lower than or equal to 100 characters!');
sendChannelMessage(channelId, `A ${type} channel has been created!`);
createChannel(msg.join(' '), type);
} else throw new Error('Invalid Channel Type!! Must be either "Text" or "Voice"');
};
} catch (err) {
setResponse('Command Error : ` ' + err.message + ' `');
};