我正在尝试创建一个不和谐的bot,该bot在其他通道之间创建通道,但是我无法实现它,因为我的代码应该创建一个通道,但是...我尝试了很多事情,这是两件事没有给出我的错误:(我用DONOTLOOK代替了机器人的令牌,我不会遇到问题...)
选项1:
const Discord = require('discord.js');
const bot = new Discord.Client();
bot.login('DONOTLOOK');
bot.on('ready', () => {
console.log('Logged in as ${bot.user.tag}!');
});
bot.on('message', msg => {
if (msg.content === 'ping') {
msg.reply('Pong!');
var server = msg.guild;
bot.channels.add("anewchannel", {type: 0});
}
});
选项2:
const Discord = require('discord.js');
const bot = new Discord.Client();
bot.login('DONOTLOOK');
bot.on('ready', () => {
console.log(`Logged in as ${bot.user.tag}!`);
});
bot.on('message', msg => {
if (msg.content === 'ping') {
msg.reply('Pong!');
var server = msg.guild;
const channel = bot.channels.add("newchannel", {type: 0});
}
});
那没有给我控制台上的任何node.js错误,机器人回答了我,但是还没有创建通道。我也看了两个引用(https://discord.com/developers/docs/resources/guild#create-guild-channel,https://discord.js.org/#/docs/main/stable/class/GuildChannelManager? scrollTo = create),没有人能解决此问题,discord.com也给了我node.js错误。上面的两个选项取自discord.js文件,它们没有出现node.js错误,但没有创建通道。如果有人可以帮助我,请。
bot.on('message', msg => {
if (msg.content === 'channel') {
message.guild.channels.create('Text', {
type: 'text',
permissionOverwrites: [
{
id: message.guild.id,
allow: ['VIEW_CHANNEL'],
}]
})
message.channel.send("Channel Created!)
}
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句