Files

31 lines
813 B
JavaScript

const fs = require('fs');
const path = require('path');
// Load the JSON file
const copypastaFilePath = path.join(
__dirname,
'./tts-copypasta-hall-of-fame.json'
);
let copypastaData = null;
if (fs.existsSync(copypastaFilePath)) {
copypastaData = JSON.parse(fs.readFileSync(copypastaFilePath, 'utf8'));
}
module.exports = async message => {
if (message.content.toLowerCase().includes('cco')) {
// Select a random object from the JSON data
if (!copypastaData) {
await message.reply('I miss Charl');
} else {
const randomIndex = Math.floor(
Math.random() * copypastaData?.messages.length
);
const randomCopypasta = copypastaData.messages[randomIndex];
// Reply with the content key value
await message.reply(randomCopypasta.content);
}
}
};