Javascript TypeError:无法读取属性';id';未定义节点的定义
我正在用RejectionDB设置本地化,并使用Eris discord库,但我不断遇到以下错误 TypeError:无法读取未定义的属性“id” 我已经添加了Javascript TypeError:无法读取属性';id';未定义节点的定义,javascript,node.js,discord,eris-discord,Javascript,Node.js,Discord,Eris Discord,我正在用RejectionDB设置本地化,并使用Eris discord库,但我不断遇到以下错误 TypeError:无法读取未定义的属性“id” 我已经添加了msg,因此我可以执行msg.author.id,但它仍然无法解决我的问题 function t (msg, context, object = { locale: 'en' }, values = {}) { let userLocale; if (object.ownerID) { userLocal
msg
,因此我可以执行msg.author.id
,但它仍然无法解决我的问题
function t (msg, context, object = { locale: 'en' }, values = {}) {
let userLocale;
if (object.ownerID) {
userLocale = this.r.table('locales').get(msg.author.id);
}
let string = (locales[userLocale] || (locales[object.locale] || locales['en']));
process.send({ name: 'log', msg: msg.author.id }); // Error
let processing = 'Translation for this command has not been found, please report it to Support!';
if (string) {
processing = string;
for (let part of context.split('.')) {
processing = processing[part];
}
}
let placeholders = processing.match(/{{[^{}]+}}/g);
for (let hold in placeholders) {
let str = placeholders[hold];
processing = processing.replace(str, values[str.replace('{{', '').replace('}}', '')]);
}
return processing;
}
global.t = t;
module.exports = { loadLocales, t };
我希望它打印
153286414212005888
(我的Discord ID),但只是错误,打印未定义。什么是msg.author
?谁在调用此方法,什么作为msg对象传递?在尝试访问它之前,我会检查它。@JackBashford是运行该命令的作者。@ETLegacy,如果调用此方法,必须传入参数。你在传递什么?@tomerpacifi,你肯定迷路了哈哈。这是我的本地化系统,就像这样,它将向您展示我正在尝试做什么(这不是我的代码,而是类似的东西)。