addcallback command

pull/29/head
Matthew 2020-11-23 14:52:55 -05:00
parent 0fe3435440
commit 3f25cd8f34
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
4 changed files with 87 additions and 0 deletions

62
src/commands/callback.ts Normal file
View File

@ -0,0 +1,62 @@
import PhoneNumber from 'awesome-phonenumber';
import axios from 'axios';
import { Message, TextChannel } from 'eris';
import { Client, Command, RichEmbed } from '../class';
export default class Callback extends Command {
constructor(client: Client) {
super(client);
this.name = 'callback';
this.description = 'Requests a Callback from a Technican.\nPlease use `-` to separate the number if needed. E.x. 202-750-2585.\nDo note, we are unable to dial international numbers outside of the US and Canada.';
this.usage = 'callback <the number you want us to call>';
this.aliases = ['cb'];
this.permissions = 0;
this.guildOnly = false;
this.enabled = true;
}
public async run(message: Message, args: string[]) {
try {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
if (message.channel.type === 0) await message.delete();
const member = this.mainGuild.members.get(message.author.id);
if (!member) return this.error(message.channel, 'Unable to fetch member.');
const phone = new PhoneNumber(args.join(' '), 'US');
if (!phone.isValid()) return this.error(message.channel, 'The number you have entered is invalid.');
const embed = new RichEmbed();
embed.setTitle('Callback Request');
embed.setDescription('Please dial `9` first to reach an the external trunk. For example, to dial 202-750-2585 you would dial 92027502585 on your device.\n\n*Please react with <:modSuccess:578750988907970567> on this message if you are taking the call.*');
embed.addField('Member', `${member.user.username}#${member.user.discriminator} | <@${member.user.id}>`, true);
embed.addField('Phone Number', phone.getNumber('national'), true);
embed.addField('Phone Number Type', phone.getType(), true);
const communityReport = await this.client.db.Score.findOne({ userID: message.author.id }).lean().exec();
if (communityReport) {
await this.client.db.Score.updateOne({ userID: message.author.id }, { $addToSet: { softInquiries: { name: 'LIBRARY OF CODE SP-US | VOIP/PBX MEMBER SUPPORT SVCS', date: new Date() } } });
const embed2 = new RichEmbed();
embed2.setTitle('Inquiry Notification');
embed2.setColor('#00FFFF');
embed2.addField('Member', `${member.user.username}#${member.user.discriminator} | <@${member.user.id}>`, true);
embed2.addField('Type', 'SOFT', true);
embed2.addField('Department/Service', 'Library of Code sp-us | VOIP/PBX Member Support SVCS'.toUpperCase(), true);
embed2.setTimestamp();
embed2.setFooter(this.client.user.username, this.client.user.avatarURL);
const log = <TextChannel> this.mainGuild.channels.get('611584771356622849');
log.createMessage({ embed: embed2 }).catch(() => {});
embed.addField('PIN', `${communityReport.pin[0]}-${communityReport.pin[1]}-${communityReport.pin[2]}`, true);
}
try {
const d = await axios.get(`https://api.cloud.libraryofcode.org/wh/info/?id=${message.author.id}&authorization=${this.client.config.internalKey}`);
embed.addField('Email Address', d.data.emailAddress, true);
embed.addField('Support Key', d.data.supportKey, true);
} catch {
this.client.util.signale.warn('No CS Account found for user.');
}
const chan = <TextChannel> this.mainGuild.channels.get('780513128240382002');
const msg = await chan.createMessage({ content: '<@&780519428873781298>', embed });
await msg.addReaction('modSuccess:578750988907970567');
return message.channel.createMessage('__**Callback Request**__\nYour callback request has been sent to our agents, you should receive a callback within 1-24 hours from the date of this request. The number you will be called from is listed below.\n\n**Callback Number:** +1 202-750-2585\n**Callback Region:** Washington, D.C., United States\n\n\n*Your number is never stored on our systems at any time, as soon as your call is taken by an agent your number is deleted from notification channels.*');
} catch (err) {
return this.client.util.handleError(err, message, this);
}
}
}

View File

@ -6,6 +6,7 @@ export { default as addredirect } from './addredirect';
export { default as apply } from './apply';
export { default as ban } from './ban';
export { default as billing } from './billing';
export { default as callback } from './callback';
export { default as delitem } from './delitem';
export { default as delmerchant } from './delmerchant';
export { default as delnote } from './delnote';

View File

@ -0,0 +1,23 @@
import { Emoji, Message, TextChannel } from 'eris';
import { Client, Event } from '../class';
export default class CallBackHandler extends Event {
public client: Client;
constructor(client: Client) {
super(client);
this.event = 'messageReactionAdd';
}
public async run(message: Message, emoji: Emoji, member: string) {
try {
if (emoji.id !== '578750988907970567' || message.channel.id !== '780513128240382002') return;
if (member === this.client.user.id) return;
const chan = <TextChannel> this.client.guilds.get(this.client.config.guildID).channels.get('780513128240382002');
const msg = await chan.getMessage(message.id);
await msg.delete();
} catch (err) {
this.client.util.handleError(err);
}
}
}

View File

@ -1,3 +1,4 @@
export { default as CallBackHandler } from './CallBackHandler';
export { default as CommandHandler } from './CommandHandler';
export { default as guildMemberAdd } from './guildMemberAdd';
export { default as ready } from './ready';