oh no
This commit is contained in:
parent
a4e568dec6
commit
befc5dc8e6
|
@ -1,6 +1,9 @@
|
||||||
const Discord = require('discord.js');
|
const Discord = require('discord.js');
|
||||||
const fs = require('fs').promises;
|
const fs = require('fs').promises;
|
||||||
|
|
||||||
|
const events = require('events');
|
||||||
|
const shutEmitter = new events.EventEmitter();
|
||||||
|
|
||||||
module.exports.meta = {
|
module.exports.meta = {
|
||||||
name: 'copypasta',
|
name: 'copypasta',
|
||||||
aliases: ['pasta'],
|
aliases: ['pasta'],
|
||||||
|
@ -24,9 +27,35 @@ module.exports.run = async (message, args) => {
|
||||||
|
|
||||||
let lines = (await fs.readFile(__dirname + '/copypastas/' + pasta))
|
let lines = (await fs.readFile(__dirname + '/copypastas/' + pasta))
|
||||||
.toString('utf-8')
|
.toString('utf-8')
|
||||||
.split('\n');
|
.split('\n')
|
||||||
|
.filter(line => line.trim() != '');
|
||||||
|
|
||||||
lines.forEach(async line => {
|
this.copypastaing[message.channel.id] = true;
|
||||||
await message.channel.send(line, { tts: true });
|
|
||||||
|
sendLine();
|
||||||
|
const interval = setInterval(sendLine, 1250);
|
||||||
|
const listener = shutEmitter.once('shut', cid => {
|
||||||
|
if (cid == message.channel.id) {
|
||||||
|
clearInterval(interval);
|
||||||
|
this.copypastaing[message.channel.id] = false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function sendLine() {
|
||||||
|
if (lines.length == 0) {
|
||||||
|
this.copypastaing[message.channel.id] = false;
|
||||||
|
clearTimeout(interval);
|
||||||
|
shutEmitter.removeListener('shut', listener);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const line = lines.shift();
|
||||||
|
await message.channel.send(line, { tts: true });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports.shut = (channelID) => {
|
||||||
|
shutEmitter.emit('shut', channelID);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.copypastaing = {}
|
4565
commands/copypastas/beemovie
Normal file
4565
commands/copypastas/beemovie
Normal file
File diff suppressed because it is too large
Load diff
16
commands/stop.js
Normal file
16
commands/stop.js
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
const Discord = require('discord.js');
|
||||||
|
|
||||||
|
module.exports.meta = {
|
||||||
|
name: 'stop',
|
||||||
|
aliases: ['stfu', 'shut'],
|
||||||
|
staffOnly: false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {Discord.Message} message
|
||||||
|
* @param {Array<string>} args
|
||||||
|
*/
|
||||||
|
module.exports.run = async (message, args) => {
|
||||||
|
require('./copypasta').shut(message.channel.id);
|
||||||
|
}
|
|
@ -33,6 +33,9 @@ client.on('message', message => {
|
||||||
|
|
||||||
logger.info(`[CMD] ${message.author.id} ${message.author.tag} => ${cmdName} ${args.join(' ')}`);
|
logger.info(`[CMD] ${message.author.id} ${message.author.tag} => ${cmdName} ${args.join(' ')}`);
|
||||||
|
|
||||||
|
if (cmd.meta?.name != 'stop' && require('../commands/copypasta').copypastaing[message.channel?.id])
|
||||||
|
return message.react('810153990733561876').catch(console.warn);
|
||||||
|
|
||||||
if (cmd.meta?.staffOnly && !message.member.permissions.has('ADMINISTRATOR')) {
|
if (cmd.meta?.staffOnly && !message.member.permissions.has('ADMINISTRATOR')) {
|
||||||
logger.warn(`${message.author.tag} => Refusing to run staff command`);
|
logger.warn(`${message.author.tag} => Refusing to run staff command`);
|
||||||
message.channel.send(
|
message.channel.send(
|
||||||
|
|
Loading…
Reference in a new issue