我正在尝试制作一个可以发送图像的JS机器人

时间:2020-09-09 16:04:33

标签: javascript node.js discord.js bots

const Discord = require('discord.js');
const client = new Discord.Client();
const PREFIX = "!";

client.on("message", (message) => {
  let args = message.content.substring(PREFIX.length).split(" ");

  switch (args[0]) {
    case "kanye":
      message.channel.send('kanye kisses kanye; colorized')
      const attachment = new attachment('./kanyek.jpeg')
      console.log('kanye succesfully scoopity poopity')

      break;
  }
});

在终端中,我收到错误ReferenceError:初始化前无法访问“附件”。请告知。

1 个答案:

答案 0 :(得分:0)

      const attachment = new attachment('./kanyek.jpeg')

attachment具有与附件构造函数完全相同的名称。就像在说

let ab = ab + 1

没有意义。因此将附件更改为其他内容

const attach = new Attachment('./kanyek.jpeg')