【发布时间】:2023-03-27 02:21:01
【问题描述】:
我正在尝试做一个不和谐的机器人来创建频道等,但我无法实现它,因为我的代码应该创建一个频道但是...我尝试了很多东西,这两个没有'没有给我错误:(我用 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 错误,但没有创建通道。如果有人可以帮助我,请。
【问题讨论】:
标签: discord.js