[英]Why am I getting this instead of a string?
這是我目前有效的代碼,因為它添加了一個點並按原樣保存。 但是,當我嘗試讓機器人說“[object Object]haha”時。 我怎樣才能解決這個問題? 代碼:
var davebal = 0;
bot.on('message', (msg) => {
if (msg.content == '-readdata') {
let rawdata = fs.readFileSync(msg.author + '.json');
let student = JSON.parse(rawdata);
msg.reply(student + 'haha');
console.log(student);
}
if (msg.content == '-add') {
if (msg.author == '349463140229971989') {
davebal += 1;
msg.reply('Az új számlád = ' + davebal);
}
}
if (msg.content == '-savedata') {
let balance = {
balancefor: davebal,
};
let data = JSON.stringify(balance);
fs.writeFileSync(msg.author + '.json', data);
}
});
我相信這是因為 student 是一個對象,我建議從對象中獲取一個屬性,例如student.name
或其他東西,而不僅僅是student
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.