Discord机器人简单地编辑自己的消息会给我带来错误


module.exports = {
name: 'hack',
execute: function(message, args) {
const user = message.mentions.users.first() || args[0];
const member = message.guild.member(user);
if (member) {
message.channel
.send('Scrambling Through Database')
.then((message) => {
setTimeout(function() {
message.edit(`Working on hack`);
}, 4000);
});
setTimeout(function() {
message.edit(`Inserting Trojan File on 💻:computer_mouse:`);
}, 2700);
setTimeout(function() {
message.edit(member + ` Leaking there passwords to the russians`);
}, 1700);
setTimeout(function() {
message.edit(`Deleting saved passwords`);
}, 1700);
setTimeout(function() {
message.edit(`Deleted Epic Account`);
}, 1700);
setTimeout(function() {
message.edit(`Sent a screenshot of there browser history to there friends`);
}, 1700);
setTimeout(function() {
message.edit(`Leaking IP Address`);
}, 1700);
setTimeout(function() {
message.edit(`Leaking users gmail account`);
}, 1700);
setTimeout(function() {
message.edit(`Completing hack`);
}, 3700);
setTimeout(function() {
message.edit(`Deleting traces`);
}, 2000);
setTimeout(function() {
message.edit(`Deleting traces...`);
}, 2000);
setTimeout(function() {
message.edit(`Copied User Details`);
}, 2000);
setTimeout(function() {
message.edit(`A successful hack was complete and it was real`);
}, 3000);
} else {
message.channel.send(
'Who are you even trying to hack? Is it that tough to mention a user?'
);
}
},
};

所以这是一个简单的!hack @user命令,在你使用该命令后,机器人只会发送一条消息,并多次编辑它的消息,但由于某种原因,我遇到了一个错误。错误如下:

未处理的PromiseRetention警告:DiscordAPI错误:无法编辑其他用户编写的消息

;消息";变量具有完全相同的名称;消息";client.on('message')中的变量,所以将其更改为"msg",一切都会正常工作:

module.exports = {
name: 'hack',
execute: function(message, args) {
const user = message.mentions.users.first() || args[0];
const member = message.guild.member(user);
if (member) {
message.channel
.send('Scrambling Through Database')
.then((msg) => {
setTimeout(function() {
msg.edit(`Working on hack`);
}, 4000);
});
// all codings
setTimeout(function() {
msg.edit(`A successful hack was complete and it was real`);
}, 3000);
} else {
message.channel.send(
'Who are you even trying to hack? Is it that tough to mention a user?'
);
}
},
};

相关内容

最新更新