import * as dotenv from 'dotenv';
dotenv.config();
import { login } from 'masto';
import expresspkg from 'express';
const { jsonContent } = expresspkg;
import * as fspkg from 'fs';
const { fs } = fspkg;

console.log("selfcarebot is starting...");


const masto = await login({
    url: process.env.URL,
    accessToken: process.env.ACCESS_TOKEN,
});

const jsonData = JSON.parse(fspkg.readFileSync('dataset1.json', 'utf-8', (error, data, status) => {
    if (error){
        console.log(error);
        return;
    }
    console.log(JSON.parse(data));
    console.log(JSON.parse(status));
}))

const stat = jsonData[stat];
var random = jsonData[stat][Math.floor(Math.random()*jsonContent[stat].length)];

const stati = await masto.statuses.create({
    status: `${random} selfcare! 🌸`,
    visibility: 'public',
  });
  
console.log(stati.url);