类型错误:message.guild.channels.forEach 不是一个函数
2020-03-26
230
我想制作一个 Discord 机器人,但我被困在这里。这是我的代码:
const Discord = require('discord.js');
const client = new Discord.Client();
client.once('ready', () => {
console.log('Ready!');
});
client.login('xxx');
client.on('message', message =>{
if(message.author.id == "xxx") {
if(message.content === "!bye") {
message.guild.channels.forEach(channel => channel.delete())
}
}
})
它显示:
message.guild.channels.forEach is not a function
我想知道为什么它对我说。(抱歉我的英语不好)
1个回答
在 discord 12 中,您需要使用新类
channelManager
const Discord = require('discord.js');
const client = new Discord.Client();
client.once('ready', () => {
console.log('Ready!');
});
client.login('xxx');
client.on('message', message =>{
if(message.author.id == "xxx") {
if(message.content === "!bye") {
message.guild.channels.cache.forEach(channel => channel.delete())
}
}
})
Cipher
2020-03-26