Skip to content
the poor coder

send file discord js v12

Poor Man
Published
Reading time
1 min read

If you want to send a file with Discord.js v12, the best way to do so is to use the MessageAttachment class. This class allows you to create a new attachment object, which can then be sent as part of a message. Here's an example of how to send a file with Discord.js v12:

Text
const Discord = require('discord.js');
const message = new Discord.Message();

const attachment = new Discord.MessageAttachment('path/to/file.txt');

message.channel.send(attachment);

The above code will send the file located at path/to/file.txt as an attachment in the same channel as the message. You can also use the MessageAttachment class to send files with a custom name, or to send files from a URL instead of from the file system. For more details on how to do this, please refer to the Discord.js v12 documentation.

Keep going

2023

how to sort an array

How to Sort an Array If you have an array and you want to order its elements in a specific way, you need to use a sorting algorithm. There are several sorting algorithms available, but two of the most commonly used are…

javascript2 min read
2023

jquery mobile or desktop

jQuery Mobile or Desktop? As a web developer, I have had some experience with both jQuery Mobile and jQuery Desktop. Both frameworks have their pros and cons, and which one to use really depends on the specific project…

javascript1 min read
2023

node.js folder structure

Node.js Folder Structure If you are new to Node.js, it can be daunting to create a folder structure that will work for your project. The structure you choose will depend on the size and complexity of your project. Here…

javascript1 min read
ESC