【问题标题】:Discord bot simple editing its own message gives me errorDiscord bot 简单地编辑自己的消息给了我错误
【发布时间】:2020-12-31 16:27:18
【问题描述】:
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 命令,在您使用该命令后,机器人只会发送一条消息并继续多次编辑其消息,但由于某种原因我收到错误消息。 这是错误:

UnhandledPromiseRejectionWarning:DiscordAPIError:无法编辑由其他用户创作的消息

【问题讨论】:

  • 读取错误。 Cannot edit a message authored by another user 

标签: javascript node.js discord discord.js


【解决方案1】:

“message”变量与client.on('message') 中的“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?'
   );
  }
 },
};

【讨论】:

  • 现在我收到这个新错误 {msg.edit((member) + `Leaking there passwords to the russians`)}, 1700) ^ ReferenceError: msg is not defined at Timeout._onTimeout (C :\Users\admin\Desktop\Meme Hub Exclusive\commands\hack.js:17:26) at listOnTimeout (internal/timers.js:549:17) at processTimers (internal
  • 最后关闭.then()回调,而不是在第一个setTimeout()之后
猜你喜欢
  • 2022-08-24
  • 2021-05-09
  • 2021-01-28
  • 1970-01-01
  • 2018-01-28
  • 2022-01-05
  • 2017-12-18
  • 1970-01-01
  • 2021-05-03
相关资源
最近更新 更多