Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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. 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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

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

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading