【问题标题】:why my node.js discord.js bot is not sending files? (no errors) (can send messages)为什么我的 node.js discord.js 机器人不发送文件? (没有错误)(可以发送消息)
【发布时间】:2022-01-16 05:03:43
【问题描述】:

所以,我构建了一个 discord.js/node.js 机器人。并添加了一个命令'$t getmsg' 我尝试过的:

  • 发送单个文件
  • 发送两个文件
  • 检查权限

机器人应该做什么:

  • 发送消息+文件

它的作用:

  • 仅发送文本
  • 我的 CMD 没有错误

应该发送文件的代码片段:

        message.channel.send("ALL SAVED MESSAGES. if you can't see any files, I don't have permission to upload.", {
            files: [
              "./messages/savedmessages.txt",
              "./messages/messages.txt"
            ]
          });

【问题讨论】:

    标签: node.js json discord.js


    【解决方案1】:

    channel.send 最多只接受一个参数,如果你有多个,就像你做的那样,你必须将它们全部作为一个对象传递。也就是说你必须像这样将你的消息添加到对象中:

    message.channel.send({
        content: "ALL SAVED MESSAGES. if you can't see any files, I don't have permission to upload.",
        files: [
            "./messages/savedmessages.txt",
            "./messages/messages.txt"
        ]
    });
    

    【讨论】:

      猜你喜欢
      • 2019-09-20
      • 2021-05-08
      • 2020-12-03
      • 2021-05-23
      • 2021-08-18
      • 2020-02-26
      • 2020-09-28
      • 2020-05-18
      • 2021-11-30
      相关资源
      最近更新 更多