【发布时间】:2021-10-25 21:06:30
【问题描述】:
我在控制台中收到此错误:TypeError: Cannot read property 'channels' of undefined。
导致问题的代码:
const channel = guild.channels.cache.find(c => c.type === 'text' && channel.permissionsFor(guild.me).has('SEND_MESSAGES'))
Index.js:
client.on("guildCreate", guild => {
client.commands.get("joinserver").execute(guild)
});
加入服务器.js:
const Discord = require("discord.js")
module.exports = {
name: 'joinserver',
description: '',
execute(message, args, client, guild) {
const channel = guild.channels.cache.find(c => c.type === 'text' && channel.permissionsFor(guild.me).has('SEND_MESSAGES'))
const embeds = new Discord.MessageEmbed()
channel.send(embeds)
}
}
【问题讨论】:
标签: javascript node.js discord discord.js