TypeError:无法读取未定义的node.js的属性“ id”

时间:2019-06-23 08:04:21

标签: javascript node.js discord eris

我正在使用rethinkdb设置本地化并使用Eris discord库,但是我一直在跟踪错误,

  

TypeError:无法读取未定义的属性“ id”。

我添加了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),但是会出错并打印未定义。

0 个答案:

没有答案