2019-10-20 20:26:49 -04:00
|
|
|
import { Message } from 'eris';
|
2019-10-28 16:21:04 -04:00
|
|
|
import { Client } from '..';
|
2019-10-20 20:26:49 -04:00
|
|
|
import { Command } from '../class';
|
|
|
|
|
|
|
|
export default class Announce extends Command {
|
|
|
|
constructor(client: Client) {
|
|
|
|
super(client);
|
|
|
|
this.name = 'announce';
|
|
|
|
this.description = 'Sends an announcement to all active terminals';
|
2019-10-28 16:21:04 -04:00
|
|
|
this.usage = `${this.client.config.prefix}announce Hi there! | ${this.client.config.prefix}announce -e EMERGENCY!`;
|
2019-10-20 20:26:49 -04:00
|
|
|
this.aliases = ['ann'];
|
2020-01-03 10:15:30 -05:00
|
|
|
this.permissions = { roles: ['662163685439045632'] };
|
2019-10-20 20:26:49 -04:00
|
|
|
this.enabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async run(message: Message, args?: string[]) {
|
|
|
|
try {
|
|
|
|
if (!args.length) return this.client.commands.get('help').run(message, [this.name]);
|
|
|
|
const notification = await message.channel.createMessage(`${this.client.stores.emojis.loading} ***Sending announcement, please wait...***`);
|
2019-10-28 16:21:04 -04:00
|
|
|
if (args[0] === '-e') await this.client.util.exec(`echo "\n\n**************************************************************************\nEMERGENCY SYSTEM BROADCAST MESSAGE | Library of Code sp-us (root enforced)\n--------------------------------------------------------------------------\n\n\n${args.slice(1).join(' ').trim()}\n\n\n\n\n\n\n\n\n\n\n\n\n" | wall -n`);
|
|
|
|
else await this.client.util.exec(`echo "\nSYSTEM BROADCAST MESSAGE | Library of Code sp-us (root enforced)\n\n\n${args.join(' ').trim()}" | wall -n`);
|
2019-10-20 20:26:49 -04:00
|
|
|
message.delete();
|
2019-10-21 19:57:58 -04:00
|
|
|
return notification.edit(`${this.client.stores.emojis.success} ***Sent${args[0] === '-e' ? ' emergency' : ''} announcement to all active terminals***`);
|
2019-10-20 20:26:49 -04:00
|
|
|
} catch (error) {
|
|
|
|
return this.client.util.handleError(error, message, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|