Discord 获取错误“;函数(){[本机代码]}";

Discord 获取错误“;函数(){[本机代码]}";,discord,discord.js,Discord,Discord.js,我正在制作一个discord机器人,并试图让它在通道中说出错误 它没有在通道中指出错误,而是说“function(){[native code]}” 我的代码: module.exports = { name:"ping", description: "yes ping", execute(message, args) { if(message.member.roles.cache.has('6812103

我正在制作一个discord机器人,并试图让它在通道中说出错误

它没有在通道中指出错误,而是说“function(){[native code]}”

我的代码:

module.exports = {
    name:"ping",
    description: "yes ping",
    execute(message, args) {
    
        if(message.member.roles.cache.has('681210322090197005')){
            message.channel.send('wow, now thats cool! you have permissions!')


        } else {
            message.channel.send("**[Permission ERROR]** It looks like you don't have access to this command!")
            message.member.roles.add('681210323981828147').catch(message.channel.send(console.error)); // doesnt return the error in the channel!!
        }

    
    }
}
message.member.roles.add(“681210323981828147”).catch(err=>{
if(err)返回message.channel.send(“错误:+err”);
});

这会将错误发送到通道中。您想发送
console.error
,这是不可能的,因为
console.error
是一个将错误记录到控制台的函数。

为什么要尝试发送
console.error
?你希望它包含什么?它是一个函数,用于将错误记录到控制台。不是要得到的财产。。。控制台的最后一个错误是什么?没有错误。你的意思是像
.catch(ex=>console.error(ex))