Home > database >  why my node.js discord.js bot is not sending files? (no errors) (can send messages)
why my node.js discord.js bot is not sending files? (no errors) (can send messages)

Time:12-13

So, I built a discord.js/node.js bot. and added a command '$t getmsg' what I have tried:

  • 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

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

CodePudding user response:

channel.send only takes a maximum of one argument, if you have multiple, as you do, you must pass them all as an object. That is to say you must add your message to the object like so:

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