我正在尝试制作一个设置您的服务器的机器人,并且希望它删除服务器中的每个通道。这是我当前的脚本及其说法,
“ TypeError:message.guild.channels.forEach不是函数”
message.guild.channels.forEach(channel => channel.delete())
答案 0 :(得分:1)
好像您正在使用Discord JS v12。请阅读this文章以查看此版本中的更改。
client.guilds.cache.forEach(guild => { // Looping through the guilds.
guild.channels.cache.forEach(channel => { // Looping through the guild channels.
channel.delete().catch(error => { // Deleting the channel(s) and catching any errors.
console.log(`Couldn't delete ${channel.name}.`)
});
});
});