Discord- DM user files

Does anyone know how to make a bot send files into someone’s DMs? For example a user to run !test and the bot DMs the user a file named “test.txt” and “test2.txt”?

DMChannel.send()

MessageAttachment

1 Like

So do I just do
if(command === “test”) {
DMChannel.send()
test.txt ?

No. You appear to be new to Javascript, I would recommend you actually learn the basics first.

The proper way to use the above references would be something like

const MessageAttachment = require('discord.js');


// inside your message event
if (command === 'test') {
message.author.send({
files: [
new MessageAttachment('test.txt'),
new MessageAttachment('test2.txt'),
],
}); 
/* assuming you have the message variable 
defined as message, otherwise whatever you've
defined the message variable as.
*/
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.