This snippet will help you write your JSON data in an attachment and send it over Discord. Check the comments below and fill out the necessary data, and press Run. Note that the JSON data could be from anywhere, such as Google Sheets data.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const CHANNEL_ID = `CHANNEL_ID`; //Channel ID where you want to send the attachment
const fileName = `file`; //This will be the file name of the attachment
//The json goes here:
let json = [
{
a: 1,
b: 2,
c: 3,
},
];
await lib.discord.channels['@0.3.2'].messages.create({
channel_id: `${CHANNEL_ID}`,
content: ``,
attachments: [
{
file: Buffer.from(JSON.stringify(json)),
filename: `${fileName}.json`,
description: ``,
},
],
});