Javascript bio[message.author.id].join(";)不是函数
自从我提出上一个问题以来,我一直在尝试让它工作,但在通过更新的Javascript bio[message.author.id].join(";)不是函数,javascript,github,heroku,discord.js,Javascript,Github,Heroku,Discord.js,自从我提出上一个问题以来,我一直在尝试让它工作,但在通过更新的setBio命令成功获取过去的Bio后,尝试执行profile命令时出现错误: bio[message.author.id]。加入不是一个函数 我已经开始意识到这个问题,但我不知道如何正确地解决它 以下是发生错误的代码: case 'setBio': if(!bio[message.author.id]) { let messages = message.channel.messages;
setBio
命令成功获取过去的Bio后,尝试执行profile
命令时出现错误:
bio[message.author.id]。加入不是一个函数
我已经开始意识到这个问题,但我不知道如何正确地解决它
以下是发生错误的代码:
case 'setBio':
if(!bio[message.author.id]) {
let messages = message.channel.messages;
let authorMessages = messages.filter(m => m.author.id === message.author.id);
let setBioCommands = authorMessages.filter(m => m.content.startsWith('!setBio'));
let firstBio = setBioCommands.last();
message.channel.send('I found a Bio you have previously set. Do you want to confirm the change to that Bio?').then(r => r.delete(10000));
message.react('✅').then(() => message.react('❎'));
const filter = (reaction, user) => {
return ['✅', '❎'].includes(reaction.emoji.name) && user.id === message.author.id;
};
message.awaitReactions(filter, { max: 1, time: 10000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === '✅') {
bio[message.author.id] = firstBio
message.reply('Past Bio successfully restored!')
.then(msg => msg.delete(3000));
}
else {
message.reply('Okey, I\'ll delete this Bio.')
.then(msg => msg.delete(3000));
}
})
.catch(collected => {
message.channel.send('You didn\'t respond, so I\'ll throw this Bio into the abyss. *Buh-bye!*');
});
} else {
let newArr = args.slice(1)
bio[message.author.id] = newArr
message.channel.send('Your bio has been changed!')
.then(msg => msg.delete(3000));
}
break;
case 'profile':
if(!bio[message.author.id]) {
return message.channel.send('Sorry, please set a bio with `!setBio` to view your profile!')
.then(msg => msg.delete(3000));
} else {
const embed = new Discord.RichEmbed()
.setTitle('__' + message.author.username + '\'s Profile__')
.addField(`Bio:`, bio[message.author.id].join(" ")) /// this is where the error is
.setColor(message.member.colorRole.color)
.setThumbnail(message.author.avatarURL)
message.channel.send(embed);
}
break;
该错误告诉您,bio[message.author.id]
没有.join()
方法.join()
通常用于具有这种方法的数组。您可能希望bio[message.author.id]
是一个数组,但它可能是另一个对象
尝试登录bio[message.author.id]
以更好地了解后台发生的事情(调试过程),并从那里继续。bio[message.author.id]@akashbhandwarkar不是数组:)的价值是什么。join()
是一种数组
方法,看起来像bio[message.author.id]
不是数组。@akashbhandwarkarbio[message.author.id]=newArr
我根本不知道如何解决这个问题。我不知道如何将bio[message.author.id]
专门记录到调试器中。检查console.log()
。在测试之后,自从使用winston
进行控制台日志记录以来,我遇到了一个问题。