obama-bot/commands/copypasta.js

27 lines
743 B
JavaScript
Raw Normal View History

2020-12-27 12:57:35 +00:00
const Discord = require('discord.js');
const fs = require('fs').promises;
module.exports.meta = {
name: 'copypasta',
aliases: ['pasta'],
staffOnly: false,
epicOnly: true
}
module.exports.run = async (message, args) => {
let copypastas = await fs.readdir(__dirname + '/copypastas');
let pasta = copypastas.find((p) => p.toLowerCase() == args[0]?.toLowerCase());
if (!pasta) {
message.channel.send(`Please choose one of: \`${copypastas.join('`, `')}\``);
return;
}
let lines = (await fs.readFile(__dirname + '/copypastas/' + pasta))
.toString('utf-8')
.split('\n');
lines.forEach(line => {
await message.channel.send(line, { tts: true });
});
}