【问题标题】:I am trying to make A JS bot who sends images我正在尝试制作一个发送图像的 JS 机器人
【发布时间】:2020-12-28 02:38:51
【问题描述】:
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:在初始化之前无法访问“附件”。请指教。

【问题讨论】:

  • 将附件命名为与您使用的附件构造函数不同的名称。 const myAttachment = new attachment('./kanyek.jpeg')

标签: javascript node.js discord.js bots


【解决方案1】:

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

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

let ab = ab + 1

没有意义。所以改变附件到别的东西

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

【讨论】:

    猜你喜欢
    • 2021-08-20
    • 1970-01-01
    • 2021-10-04
    • 2021-08-11
    • 1970-01-01
    • 2021-05-02
    • 1970-01-01
    • 2010-11-26
    • 2017-07-27
    相关资源
    最近更新 更多