我最近一直在制作一个自动审核机器人。我规定如果此人收到 30 次警告,该人将被禁止。但它却向我展示了一个错误。我试图自己修复它,但不知道问题出在哪里。这是我使用的代码:if (warns.warns.length === 30 && message.member.bannable) { embed.addField( `⛔ ${message.author.tag} has reached 30 warnings.`, `**${message.author} has been banned permanently.**`, true ); setTimeout(function() { message.member .send(banemb) .then((message) => message.member.ban({ reason: '30 warnings' })); }, 1000);}这是我得到的错误:{ "stack": "TypeError: Cannot read property 'ban' of nullat /app/app.js:157:51 at processTicksAndRejections (internal/process/task_queues.js:88:5)"}
1 回答
MYYA
TA贡献1868条经验 获得超4个赞
改为.then(message =>_.then(msg =>
因为您覆盖了消息变量,所以新message变量是null
setTimeout(function() {
message.member
.send(banemb)
.then((msg) => message.member.ban({ reason: '30 warnings' }));
}, 1000);
添加回答
举报
0/150
提交
取消