简体   繁体   English

为什么我的 node.js discord.js 机器人不发送文件? (没有错误)(可以发送消息)

[英]why my node.js discord.js bot is not sending files? (no errors) (can send messages)

So, I built a discord.js/node.js bot.所以,我构建了一个 discord.js/node.js 机器人。 and added a command '$t getmsg' what I have tried:并添加了我尝试过的命令“$ t getmsg”:

  • sending a single file发送单个文件
  • sending two files发送两个文件
  • checking the permission检查权限

what the bot should do:机器人应该做什么:

  • send the message + files发送消息+文件

what it does:它能做什么:

  • sends the text only仅发送文本
  • I got no error in the CMD CMD 没有错误

the pice of code that should send the file:应该发送文件的代码片段:

        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"
            ]
          });

channel.send only takes a maximum of one argument, if you have multiple, as you do, you must pass them all as an object. channel.send 最多只接受一个参数,如果你有多个,你必须将它们全部作为 object 传递。 That is to say you must add your message to the object like so:也就是说,您必须像这样将您的消息添加到 object 中:

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"
    ]
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM