我希望以下命令!addclass nameofclass
向管理频道发送一条消息,询问我们是否要将该类添加为频道,监听!yes
或!no
,以及是否!yes
创建该频道。我不确定guild.channels.create
应该如何正确使用。我认为我必须定义channels
,但我不知道该定义什么。
guild.channels.create({name: newclassname})
^
TypeError: Cannot read property 'create' of undefined
const Discord = require('discord.js');
const Client = new Discord.Client();
const token = 'bottoken';
const guild = 'guildToken';
const PREFIX = '!';
Client.on('ready', () => {
console.log('This Client is online!');
})
const adminchannel = Client.channels.cache.get('adminchanneltoken')
Client.on('message', message => {
let args = message.content.substring(PREFIX.length).split(" ");
switch (args[0]) {
case 'addclass':
const newclassname = args[1];
if (message.channel.id != 'addclasschanneltoken') {
Client.channels.cache.get('adminchanneltoken').send('someone wants to add "' + newclassname + '" as a class name')
Client.channels.cache.get('adminchanneltoken').send('do you want to add it? (yes or no)')
if (message.channel.id != 'adminchanneltoken') {
Client.on('message', message => {
let argsrespond = message.content.substring(PREFIX.length).split(" ");
switch (argsrespond[0]) {
case 'yes':
Client.guilds.cache.get('guildToken');
Client.channels.cache.get('guildToken');
guild.channels.create({
name: newclassname
})
.then(console.log)
.catch(console.error);
break;
case 'no':
break;
}
})
} else {}
} else {}
}
})
Client.login(token);