因此,我在玩我的欢迎消息并希望将其嵌入,我最终重新编写了所有内容以用于嵌入,但是完成后,出现了错误message is not defined
。
var welcomePath = './Storage/welcome.json';
var welcomeRead = fs.readFileSync(welcomePath);
var welcomeFile = JSON.parse(welcomeRead);
client.on('guildMemberAdd', (member) => {
var serverId = member.guild.id;
if (!welcomeFile[serverId]) {
console.log('Welcome is disabled!');
} else {
let welcomeChannel = welcomeFile[serverId].channel,
let setChannel = message.guild.channels.find(channel => channel.name === welcomeChannel);
const embed = new Discord.RichEmbed()
.setTitle("Test")
.setAuthor("Test")
.setColor(3447003)
.setDescription("Test")
.setThumbnail(message.author.avatarURL);
member.guild.channels.get(setChannel).send({
embed
});
}
});
错误与此行有关
let setChannel = message.guild.channels.find(channel => channel.name === welcomeChannel);
我确实很想学习JS,并且不断发现自己碰到了这堵砖墙,我只需要简单地寻求帮助即可。我也不确定如果您修复了message is not defined
,那么我的代码实际上可以执行任何操作。
答案 0 :(得分:0)
消息未定义,您应该寻找成员。
let setChannel = 成员 .guild.channels.find(channel => channel.name === welcomeChannel);
client.on('guildMemberAdd', (member) => {
var serverId = member.guild.id;
if (!welcomeFile[serverId]) {
console.log('Welcome is disabled!')
} else {
let welcomeChannel = welcomeFile[serverId].channel
let setChannel = member.guild.channels.find(channel => channel.name === welcomeChannel);
const embed = new Discord.RichEmbed()
.setTitle("Test")
.setAuthor("Test")
.setColor(3447003)
.setDescription("Test")
.setThumbnail(message.author.avatarURL)
member.guild.channels.get(setChannel).send({embed});
}
})