javascript 参考错误:未定义消息

8ljdwjyq  于 2023-01-04  发布在  Java
关注(0)|答案(2)|浏览(242)

您好,我想提及正在运行该命令的用户,但收到错误
这是密码!

const Discord = require("discord.js")
 
module.exports = {
  name: 'not-dropping',
  description: 'sets the dropping status!',
  
  execute(message, args) {
    if (message.channel.id === '1059798572855476245') {
      message.delete(1000);
      
      const name = ("dropping-🔴")
      message.channel.setName(name)
      message.channel.send(`Successfully set the dropping status to **${name}**\n<@${msg.author.id}> is not Dropping anymore!\nDont Ping Him in your Ticket.`)
    }
  }
}

3.我不明白问题出在哪里

yv5phkfx

yv5phkfx1#

由于错误指出“msg”未定义。
在代码“{msg.author.id}”中,您使用的是msg,而实际变量是“message”。
将其更改为{message.author.id}

gr8qqesn

gr8qqesn2#

“msg”没有这种用法
你应该用“消息”

我更改了代码中需要更改的地方:)

const Discord = require("discord.js")
 
module.exports = {
  name: 'not-dropping',
  description: 'sets the dropping status!',
  
  execute(message, args) {
    if (message.channel.id === '1059798572855476245') {
      message.delete(1000);
      
      const name = ("dropping-🔴")
      message.channel.setName(name)
      message.channel.send(`Successfully set the dropping status to **${name}**\n<@${message.author.id}> is not Dropping anymore!\nDont Ping Him in your Ticket.`)
    }
  }
}

相关问题