chore: integrate old MemoryPalace files and configure auto-commit
This commit is contained in:
30
code/junk-drawer/handleCCOMention.js
Normal file
30
code/junk-drawer/handleCCOMention.js
Normal file
@@ -0,0 +1,30 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user