rewrite all commands to use command context class

ctx
Matthew 2023-02-11 23:49:24 -05:00
parent d96b7a6011
commit 632c6197c8
64 changed files with 640 additions and 667 deletions

View File

@ -1,5 +1,5 @@
import { Message } from 'eris';
import { Client, Command, RichEmbed } from '../class';
import { Client, Command, CmdContext, RichEmbed } from '../class';
export default class AddItem extends Command {
constructor(client: Client) {
@ -11,46 +11,46 @@ export default class AddItem extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (args.length < 1) {
public async run(ctx: CmdContext) {
if (ctx.args.length < 1) {
const embed = new RichEmbed();
embed.setTitle('Whois Data Codes');
embed.addField('Languages', '**Assembly Language:** lang-asm\n**C/C++:** lang-cfam\n**C#:** lang-csharp\n**Go:** lang-go\n**Java:** lang-java\n**JavaScript:** lang-js\n**Kotlin:** lang-kt\n**Python:** lang-py\n**Ruby:** lang-rb\n**Rust:** lang-rs\n**Swift:** lang-swift\n**TypeScript:** lang-ts');
embed.addField('Operating Systems', '**Arch:** os-arch\n**Debian:** os-deb\n**CentOS:** os-cent\n**Fedora:** os-fedora\n**macOS:** os-mdarwin\n**Manjaro:** os-manjaro\n**RedHat:** os-redhat\n**Ubuntu:** os-ubuntu\n**Windows:** os-win');
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setTimestamp();
return message.channel.createMessage({ embed });
return ctx.uniCreateMessage({ embed });
}
if (args[0].split('-')[0] === 'os' && ['arch', 'deb', 'cent', 'fedora', 'manjaro', 'mdarwin', 'redhat', 'ubuntu', 'win'].includes(args[0].split('-')[1])) {
const account = await this.client.db.mongo.Member.findOne({ userID: message.member.id });
if (ctx.args[0].split('-')[0] === 'os' && ['arch', 'deb', 'cent', 'fedora', 'manjaro', 'mdarwin', 'redhat', 'ubuntu', 'win'].includes(ctx.args[0].split('-')[1])) {
const account = await this.client.db.mongo.Member.findOne({ userID: ctx.message.member.id });
if (!account) {
const newAccount = new this.client.db.mongo.Member({
userID: message.member.id,
userID: ctx.message.member.id,
additional: {
operatingSystems: [args[0].split('-')[1]],
operatingSystems: [ctx.args[0].split('-')[1]],
},
});
await newAccount.save();
} else {
await account.updateOne({ $addToSet: { 'additional.operatingSystems': args[0].split('-')[1] } });
await account.updateOne({ $addToSet: { 'additional.operatingSystems': ctx.args[0].split('-')[1] } });
}
return message.channel.createMessage(`***${this.client.util.emojis.SUCCESS} Added OS code ${args[0]} to profile.***`);
return ctx.uniCreateMessage(`***${this.client.util.emojis.SUCCESS} Added OS code ${ctx.args[0]} to profile.***`);
}
if (args[0].split('-')[0] === 'lang' && ['js', 'py', 'rb', 'ts', 'rs', 'go', 'cfam', 'csharp', 'swift', 'java', 'kt', 'asm'].includes(args[0].split('-')[1])) {
const account = await this.client.db.mongo.Member.findOne({ userID: message.member.id });
if (ctx.args[0].split('-')[0] === 'lang' && ['js', 'py', 'rb', 'ts', 'rs', 'go', 'cfam', 'csharp', 'swift', 'java', 'kt', 'asm'].includes(ctx.args[0].split('-')[1])) {
const account = await this.client.db.mongo.Member.findOne({ userID: ctx.message.member.id });
if (!account) {
const newAccount = new this.client.db.mongo.Member({
userID: message.member.id,
userID: ctx.message.member.id,
additional: {
langs: [args[0].split('-')[1]],
langs: [ctx.args[0].split('-')[1]],
},
});
await newAccount.save();
} else {
await account.updateOne({ $addToSet: { 'additional.langs': args[0].split('-')[1] } });
await account.updateOne({ $addToSet: { 'additional.langs': ctx.args[0].split('-')[1] } });
}
return message.channel.createMessage(`***${this.client.util.emojis.SUCCESS} Added language code ${args[0]} to profile.***`);
return ctx.uniCreateMessage(`***${this.client.util.emojis.SUCCESS} Added language code ${ctx.args[0]} to profile.***`);
}
return message.channel.createMessage(`***${this.client.util.emojis.ERROR} Invalid data code.***`);
return ctx.uniCreateMessage(`***${this.client.util.emojis.ERROR} Invalid data code.***`);
}
}

View File

@ -1,6 +1,6 @@
import { Message } from 'eris';
import { randomBytes } from 'crypto';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
export default class AddMerchant extends Command {
constructor(client: Client) {
@ -14,18 +14,18 @@ export default class AddMerchant extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[1]) return this.client.commands.get('help').run(message, [this.name]);
if ((Number(args[0]) !== 0) && (Number(args[0]) !== 1)) return this.error(message.channel, 'Invalid permissions.');
if ((Number(args[1]) !== 0) && (Number(args[1]) !== 1)) return this.error(message.channel, 'Invalid permissions.');
public async run(ctx: CmdContext) {
if (!ctx.args[1]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
if ((Number(ctx.args[0]) !== 0) && (Number(ctx.args[0]) !== 1)) return this.error(ctx.message.channel, 'Invalid permissions.');
if ((Number(ctx.args[1]) !== 0) && (Number(ctx.args[1]) !== 1)) return this.error(ctx.message.channel, 'Invalid permissions.');
const key = randomBytes(20).toString('hex');
const merchant = await (new this.client.db.mongo.Merchant({
name: args.slice(2).join(' '),
privileged: Number(args[0]),
type: Number(args[1]),
name: ctx.args.slice(2).join(' '),
privileged: Number(ctx.args[0]),
type: Number(ctx.args[1]),
key,
pulls: [],
})).save();
return this.success(message.channel, `Created merchant (${merchant._id}). \`${args.slice(2).join(' ')}\`\n\n\`${key}\``);
return this.success(ctx.message.channel, `Created merchant (${merchant._id}). \`${ctx.args.slice(2).join(' ')}\`\n\n\`${key}\``);
}
}

View File

@ -1,5 +1,5 @@
import { Message } from 'eris';
import { Command, Client } from '../class';
import { CmdContext, Command, Client } from '../class';
export default class AddNote extends Command {
constructor(client: Client) {
@ -12,25 +12,25 @@ export default class AddNote extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0] || args.length < 1) return this.client.commands.get('help').run(message, [this.name]);
let user = this.client.util.resolveMember(args[0], this.mainGuild)?.user;
if (!user) user = await this.client.getRESTUser(args[0]);
if (!user) return this.error(message.channel, 'The member you specified could not be found.');
public async run(ctx: CmdContext) {
if (!ctx.args[0] || ctx.args.length < 1) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
let user = this.client.util.resolveMember(ctx.args[0], this.mainGuild)?.user;
if (!user) user = await this.client.getRESTUser(ctx.args[0]);
if (!user) return this.error(ctx.message.channel, 'The member you specified could not be found.');
const note: { userID?: string, staffID: string, date: Date, category?: string, text?: string } = {
userID: user.id,
date: new Date(),
staffID: message.author.id,
staffID: ctx.message.author.id,
};
if (args[args.length - 1] !== 'edu' && args[args.length - 1] !== 'comm' && args[args.length - 1] !== 'cs') {
if (ctx.args[ctx.args.length - 1] !== 'edu' && ctx.args[ctx.args.length - 1] !== 'comm' && ctx.args[ctx.args.length - 1] !== 'cs') {
note.category = '';
note.text = args.slice(1).join(' ');
note.text = ctx.args.slice(1).join(' ');
} else {
note.category = args[args.length - 1];
note.text = args.slice(0, args.length - 1).join(' ');
note.category = ctx.args[ctx.args.length - 1];
note.text = ctx.args.slice(0, ctx.args.length - 1).join(' ');
}
const saved = await (new this.client.db.mongo.Note(note).save());
return this.success(message.channel, `Successfully created Note # \`${saved._id}\`.`);
return this.success(ctx.message.channel, `Successfully created Note # \`${saved._id}\`.`);
}
}

View File

@ -1,5 +1,4 @@
import { Message } from 'eris';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
export default class AddPromoCode extends Command {
constructor(client: Client) {
@ -13,17 +12,17 @@ export default class AddPromoCode extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
try {
const pcd = await this.client.stripe.promotionCodes.retrieve(args[0]);
const pcd = await this.client.stripe.promotionCodes.retrieve(ctx.args[0]);
const promo = new this.client.db.mongo.Promo({
code: pcd.code,
pID: args[0],
pID: ctx.args[0],
});
await promo.save();
} catch (err) {
return this.error(message.channel, 'Promotional API ID doesn\'t exist.');
return this.error(ctx.message.channel, 'Promotional API ID doesn\'t exist.');
}
}
}

View File

@ -1,5 +1,4 @@
import { Message } from 'eris';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
export default class AddRank extends Command {
constructor(client: Client) {
@ -12,30 +11,30 @@ export default class AddRank extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
if (!args[1]) return this.error(message.channel, 'Permissions are required.');
if (!args[2]) return this.error(message.channel, 'A description is required');
const role = this.client.util.resolveRole(args[0], this.mainGuild);
if (!role) return this.error(message.channel, 'The role you specified doesn\'t appear to exist.');
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
if (!ctx.args[1]) return this.error(ctx.message.channel, 'Permissions are required.');
if (!ctx.args[2]) return this.error(ctx.message.channel, 'A description is required');
const role = this.client.util.resolveRole(ctx.args[0], this.mainGuild);
if (!role) return this.error(ctx.message.channel, 'The role you specified doesn\'t appear to exist.');
const check = await this.client.db.mongo.Rank.findOne({ roleID: role.id });
if (check) return this.error(message.channel, 'This role is already self-assignable.');
if (check) return this.error(ctx.message.channel, 'This role is already self-assignable.');
let permissions: string[];
if (args[1] === '0') {
if (ctx.args[1] === '0') {
permissions = ['0'];
} else {
permissions = args[1].split(':');
permissions = ctx.args[1].split(':');
}
const entry = new this.client.db.mongo.Rank({
name: role.name,
roleID: role.id,
permissions,
description: args.slice(2).join(' '),
description: ctx.args.slice(2).join(' '),
});
await entry.save();
return this.success(message.channel, `Role ${role.name} is now self-assignable.`);
return this.success(ctx.message.channel, `Role ${role.name} is now self-assignable.`);
}
}

View File

@ -1,5 +1,4 @@
import { Message } from 'eris';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
export default class AddRedirect extends Command {
constructor(client: Client) {
@ -12,23 +11,23 @@ export default class AddRedirect extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
const check = await this.client.db.mongo.Redirect.findOne({ key: args[1].toLowerCase() });
if (check) return this.error(message.channel, `Redirect key ${args[1].toLowerCase()} already exists. Linked to: ${check.to}`);
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
const check = await this.client.db.mongo.Redirect.findOne({ key: ctx.args[1].toLowerCase() });
if (check) return this.error(ctx.message.channel, `Redirect key ${ctx.args[1].toLowerCase()} already exists. Linked to: ${check.to}`);
try {
const test = new URL(args[0]);
if (test.protocol !== 'https:') return this.error(message.channel, 'Protocol must be HTTPS.');
const test = new URL(ctx.args[0]);
if (test.protocol !== 'https:') return this.error(ctx.message.channel, 'Protocol must be HTTPS.');
} catch {
return this.error(message.channel, 'This doesn\'t appear to be a valid URL.');
return this.error(ctx.message.channel, 'This doesn\'t appear to be a valid URL.');
}
if ((/^[a-zA-Z0-9]+$/gi.test(args[1].toLowerCase().replace('-', '').trim()) === false) || args[1].toLowerCase().length > 15) return this.error(message.channel, 'Invalid key. The key must be alphanumeric and less than 16 characters.');
if ((/^[a-zA-Z0-9]+$/gi.test(ctx.args[1].toLowerCase().replace('-', '').trim()) === false) || ctx.args[1].toLowerCase().length > 15) return this.error(ctx.message.channel, 'Invalid key. The key must be alphanumeric and less than 16 characters.');
const redirect = new this.client.db.mongo.Redirect({
key: args[1].toLowerCase(),
to: args[0],
key: ctx.args[1].toLowerCase(),
to: ctx.args[0],
visitedCount: 0,
});
await redirect.save();
return this.success(message.channel, `Redirect https://loc.sh/${args[1].toLowerCase()} -> ${args[0]} is now active.`);
return this.success(ctx.message.channel, `Redirect https://loc.sh/${ctx.args[1].toLowerCase()} -> ${ctx.args[0]} is now active.`);
}
}

View File

@ -2,7 +2,7 @@
import type { AxiosError, AxiosStatic } from 'axios';
import axios from 'axios';
import { Member, Message } from 'eris';
import { Client, Command, RichEmbed } from '../class';
import { Client, CmdContext, Command, RichEmbed } from '../class';
import { CloudServicesUtil } from '../util';
export default class Apply extends Command {
@ -177,35 +177,35 @@ export default class Apply extends Command {
});
}
public async run(message: Message, args: string[]) {
if (!args[0] || args[0] === 'full') {
public async run(ctx: CmdContext) {
if (!ctx.args[0] || ctx.args[0] === 'full') {
const embed = new RichEmbed();
embed.setTitle('Instant Application Service [IAS]');
embed.setColor('#556cd6');
if (args[0] !== 'full') {
if (ctx.args[0] !== 'full') {
embed.setDescription(`*These applications are specifically targeted to you based on validation conditions. Run \`${this.client.config.prefix}apply full\` for a full list of all applications.*`);
embed.setThumbnail(message.member.avatarURL);
embed.setAuthor(message.member.username, message.member.avatarURL);
embed.setThumbnail(ctx.message.member.avatarURL);
embed.setAuthor(ctx.message.member.username, ctx.message.member.avatarURL);
}
for (const service of this.services) {
// eslint-disable-next-line no-await-in-loop
const test = await service[1].validation(message.member);
if (!test && args[0] !== 'full') continue;
const test = await service[1].validation(ctx.message.member);
if (!test && ctx.args[0] !== 'full') continue;
embed.addField(service[0], `**Description**: ${service[1].description}\n**Inquiry Type:** ${service[1].type}\n\n${service[1].saaOnly ? '*This application can only be ran as a Staff-Assisted Application and cannot be ran automatically. Please DM <@457750238208327691> to apply.*' : `*Run \`${this.client.config.prefix}apply ${service[0]}\` to apply.*`}`);
}
if (embed.fields?.length <= 0) embed.setDescription(`*We have no offers for you at this time. To see a full list of offers, please run \`${this.client.config.prefix}apply full\`.*`);
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setTimestamp();
return message.channel.createMessage({ embed });
return ctx.uniCreateMessage({ embed });
}
if (!this.services.has(args[0])) return this.error(message.channel, 'Invalid service/product name.');
const service = this.services.get(args[0]);
const test = await this.services.get(args[0]).validation(message.member);
if (!test) return this.error(message.channel, 'A condition exists which prevents you from applying, please try again later.');
if (service.saaOnly) return this.error(message.channel, 'This application can only be ran as a Staff-Assisted Application and cannot be ran automatically. Please DM <@457750238208327691> to apply.');
const msg = await this.loading(message.channel, 'Thank you for submitting an application. We are currently processing it, you will receive a DM with a decision.');
return this.client.queue.processApplication({ channelID: message.channel.id, guildID: this.mainGuild.id, messageID: msg.id }, service.url, message.author.id, service.func ? service.func.toString() : undefined);
if (!this.services.has(ctx.args[0])) return this.error(ctx.message.channel, 'Invalid service/product name.');
const service = this.services.get(ctx.args[0]);
const test = await this.services.get(ctx.args[0]).validation(ctx.message.member);
if (!test) return this.error(ctx.message.channel, 'A condition exists which prevents you from applying, please try again later.');
if (service.saaOnly) return this.error(ctx.message.channel, 'This application can only be ran as a Staff-Assisted Application and cannot be ran automatically. Please DM <@457750238208327691> to apply.');
const msg = await this.loading(ctx.message.channel, 'Thank you for submitting an application. We are currently processing it, you will receive a DM with a decision.');
return this.client.queue.processApplication({ channelID: ctx.message.channel.id, guildID: this.mainGuild.id, messageID: msg.id }, service.url, ctx.message.author.id, service.func ? service.func.toString() : undefined);
}
public static async apply(client: Client, url: string, userID: string) {

View File

@ -1,6 +1,6 @@
import moment, { unitOfTime } from 'moment';
import { Message, User } from 'eris';
import { Client, Command } from '../class';
import { User } from 'eris';
import { Client, CmdContext, Command } from '../class';
export default class Ban extends Command {
constructor(client: Client) {
@ -13,37 +13,37 @@ export default class Ban extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
const member = this.client.util.resolveMember(args[0], this.mainGuild);
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
const member = this.client.util.resolveMember(ctx.args[0], this.mainGuild);
let user: User;
if (!member) {
try {
user = await this.client.getRESTUser(args[0]);
user = await this.client.getRESTUser(ctx.args[0]);
} catch {
return this.error(message.channel, 'Cannot find user.');
return this.error(ctx.message.channel, 'Cannot find user.');
}
} else {
user = member.user;
}
try {
await this.mainGuild.getBan(args[0]);
return this.error(message.channel, 'This user is already banned.');
await this.mainGuild.getBan(ctx.args[0]);
return this.error(ctx.message.channel, 'This user is already banned.');
} catch {} // eslint-disable-line no-empty
if (member && !this.client.util.moderation.checkPermissions(member, message.member)) return this.error(message.channel, 'Permission Denied.');
message.delete();
if (member && !this.client.util.moderation.checkPermissions(member, ctx.message.member)) return this.error(ctx.message.channel, 'Permission Denied.');
ctx.message.delete();
let momentMilliseconds: number;
let reason: string;
if (args.length > 1) {
const lockLength = args[1].match(/[a-z]+|[^a-z]+/gi);
if (ctx.args.length > 1) {
const lockLength = ctx.args[1].match(/[a-z]+|[^a-z]+/gi);
const length = Number(lockLength[0]);
const unit = lockLength[1] as unitOfTime.Base;
momentMilliseconds = moment.duration(length, unit).asMilliseconds();
reason = momentMilliseconds ? args.slice(2).join(' ') : args.slice(1).join(' ');
if (reason.length > 512) return this.error(message.channel, 'Ban reasons cannot be longer than 512 characters.');
reason = momentMilliseconds ? ctx.args.slice(2).join(' ') : ctx.args.slice(1).join(' ');
if (reason.length > 512) return this.error(ctx.message.channel, 'Ban reasons cannot be longer than 512 characters.');
}
await this.client.util.moderation.ban(user, message.member, momentMilliseconds, reason);
return this.success(message.channel, `${user.username}#${user.discriminator} has been banned.`);
await this.client.util.moderation.ban(user, ctx.message.member, momentMilliseconds, reason);
return (await this.success(ctx.message.channel, `${user.username}#${user.discriminator} has been banned.`)).delete();
}
}

View File

@ -1,9 +1,8 @@
import axios from 'axios';
import moment from 'moment';
import { Message } from 'eris';
import { randomBytes } from 'crypto';
import { v4 as uuid } from 'uuid';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
import Billing_T3 from './billing_t3';
export default class Billing extends Command {
@ -18,14 +17,14 @@ export default class Billing extends Command {
this.enabled = true;
}
public async run(message: Message) {
public async run(ctx: CmdContext) {
const response = <{
found: boolean,
emailAddress?: string,
tier?: number,
supportKey?: string,
}> (await axios.get(`https://api.cloud.libraryofcode.org/wh/info?id=${message.author.id}&authorization=${this.client.config.internalKey}`)).data;
if (!response.found) return this.error(message.channel, 'CS Account not found.');
}> (await axios.get(`https://api.cloud.libraryofcode.org/wh/info?id=${ctx.message.author.id}&authorization=${this.client.config.internalKey}`)).data;
if (!response.found) return this.error(ctx.message.channel, 'CS Account not found.');
const portalKey = randomBytes(50).toString('hex');
const uid = uuid();
@ -35,8 +34,8 @@ export default class Billing extends Command {
});
const portal = new this.client.db.mongo.CustomerPortal({
key: portalKey,
username: message.author.username,
userID: message.author.id,
username: ctx.message.author.username,
userID: ctx.message.author.id,
emailAddress: response.emailAddress,
expiresOn: moment().add(5, 'minutes').toDate(),
used: false,
@ -44,9 +43,9 @@ export default class Billing extends Command {
await portal.save();
await redirect.save();
const chan = await this.client.getDMChannel(message.author.id);
const chan = await this.client.getDMChannel(ctx.message.author.id);
await chan.createMessage(`__***Billing Account Portal***__\nClick here: https://loc.sh/${uid}\n\nYou will be redirected to your billing portal, please note the link expires after 5 minutes.`)
.catch(() => this.error(message.channel, 'Failed to privately send your billing portal link to you.'));
return this.success(message.channel, 'Your Billing Portal information has been DMed to you.');
.catch(() => this.error(ctx.message.channel, 'Failed to privately send your billing portal link to you.'));
return this.success(ctx.message.channel, 'Your Billing Portal information has been DMed to you.');
}
}

View File

@ -2,7 +2,7 @@ import axios from 'axios';
import Database from 'cr-db';
import { Message } from 'eris';
import type { Stripe } from 'stripe';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
export default class Billing_T3 extends Command {
constructor(client: Client) {
@ -15,22 +15,22 @@ export default class Billing_T3 extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
await message.delete();
public async run(ctx: CmdContext) {
await ctx.message.delete();
const response = <{
found: boolean,
emailAddress?: string,
tier?: number,
supportKey?: string,
}>(await axios.get(`https://api.cloud.libraryofcode.org/wh/info?id=${message.author.id}&authorization=${this.client.config.internalKey}`)).data;
if (!response.found) return this.error(message.channel, 'CS Account not found.');
}>(await axios.get(`https://api.cloud.libraryofcode.org/wh/info?id=${ctx.message.author.id}&authorization=${this.client.config.internalKey}`)).data;
if (!response.found) return this.error(ctx.message.channel, 'CS Account not found.');
const customer = await this.client.db.mongo.Customer.findOne({ userID: message.author.id });
if (!customer) return this.error(message.channel, `You do not have a Customer Account. Please run \`${this.client.config.prefix}billing\`, once you visit the Billing Portal via the URL given to you, please try again.`);
const customer = await this.client.db.mongo.Customer.findOne({ userID: ctx.message.author.id });
if (!customer) return this.error(ctx.message.channel, `You do not have a Customer Account. Please run \`${this.client.config.prefix}billing\`, once you visit the Billing Portal via the URL given to you, please try again.`);
let promoCode;
if (args[0]) {
promoCode = await this.client.db.mongo.Promo.findOne({ code: args[0].toUpperCase() });
if (ctx.args[0]) {
promoCode = await this.client.db.mongo.Promo.findOne({ code: ctx.args[0].toUpperCase() });
}
let subscription: Stripe.Response<Stripe.Subscription>;
@ -45,14 +45,14 @@ export default class Billing_T3 extends Command {
promotion_code: promoCode ? promoCode.id : undefined,
});
} catch (err) {
return this.error(message.channel, `Error creating subscription.\n\n${err}`);
return this.error(ctx.message.channel, `Error creating subscription.\n\n${err}`);
}
await this.client.stripe.invoices.finalizeInvoice(subscription.latest_invoice.toString());
const invoice = await this.client.stripe.invoices.retrieve(subscription.latest_invoice.toString());
const chan = await this.client.getDMChannel(message.author.id);
const chan = await this.client.getDMChannel(ctx.message.author.id);
await chan.createMessage(`__**Invoice for New Subscription**__\n${invoice.hosted_invoice_url}\n\n*Please click on the link above to pay for your subscription.*`);
return this.success(message.channel, 'Transaction processed.');
return this.success(ctx.message.channel, 'Transaction processed.');
}
}

View File

@ -1,5 +1,5 @@
import { Message } from 'eris';
import { Client, Command, RichEmbed } from '../class';
import { Client, CmdContext, Command, RichEmbed } from '../class';
export default class DelItem extends Command {
constructor(client: Client) {
@ -11,32 +11,32 @@ export default class DelItem extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (args.length < 1) {
public async run(ctx: CmdContext) {
if (ctx.args.length < 1) {
const embed = new RichEmbed();
embed.setTitle('Whois Data Codes');
embed.addField('Languages', '**Assembly Language:** lang-asm\n**C/C++:** lang-cfam\n**C#:** lang-csharp\n**Go:** lang-go\n**Java:** lang-java\n**JavaScript:** lang-js\n**Kotlin:** lang-kt\n**Python:** lang-py\n**Ruby:** lang-rb\n**Rust:** lang-rs\n**Swift:** lang-swift\n**TypeScript:** lang-ts');
embed.addField('Operating Systems', '**Arch:** os-arch\n**Debian:** os-deb\n**CentOS:** os-cent\n**Fedora:** os-fedora\n**macOS:** os-mdarwin\n**Manjaro:** os-manjaro\n**RedHat:** os-redhat\n**Ubuntu:** os-ubuntu\n**Windows:** os-win');
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setTimestamp();
return message.channel.createMessage({ embed });
return ctx.uniCreateMessage({ embed });
}
if (args[0].split('-')[0] === 'os' && ['arch', 'deb', 'cent', 'fedora', 'manjaro', 'mdarwin', 'redhat', 'ubuntu', 'win'].includes(args[0].split('-')[1])) {
const account = await this.client.db.mongo.Member.findOne({ userID: message.member.id });
if (ctx.args[0].split('-')[0] === 'os' && ['arch', 'deb', 'cent', 'fedora', 'manjaro', 'mdarwin', 'redhat', 'ubuntu', 'win'].includes(ctx.args[0].split('-')[1])) {
const account = await this.client.db.mongo.Member.findOne({ userID: ctx.message.member.id });
if (account?.additional.operatingSystems.length < 1) {
return message.channel.createMessage(`***${this.client.util.emojis.ERROR} You don't have any operating systems to remove.***`);
return ctx.uniCreateMessage(`***${this.client.util.emojis.ERROR} You don't have any operating systems to remove.***`);
}
await account.updateOne({ $pull: { 'additional.operatingSystems': args[0].split('-')[1] } });
return message.channel.createMessage(`***${this.client.util.emojis.SUCCESS} Removed OS code ${args[0]} from profile.***`);
await account.updateOne({ $pull: { 'additional.operatingSystems': ctx.args[0].split('-')[1] } });
return ctx.uniCreateMessage(`***${this.client.util.emojis.SUCCESS} Removed OS code ${ctx.args[0]} from profile.***`);
}
if (args[0].split('-')[0] === 'lang' && ['js', 'py', 'rb', 'ts', 'rs', 'go', 'cfam', 'csharp', 'swift', 'java', 'kt', 'asm'].includes(args[0].split('-')[1])) {
const account = await this.client.db.mongo.Member.findOne({ userID: message.member.id });
if (ctx.args[0].split('-')[0] === 'lang' && ['js', 'py', 'rb', 'ts', 'rs', 'go', 'cfam', 'csharp', 'swift', 'java', 'kt', 'asm'].includes(ctx.args[0].split('-')[1])) {
const account = await this.client.db.mongo.Member.findOne({ userID: ctx.message.member.id });
if (account?.additional.langs.length < 1) {
return message.channel.createMessage(`***${this.client.util.emojis.ERROR} You don't have any languages to remove.***`);
return ctx.uniCreateMessage(`***${this.client.util.emojis.ERROR} You don't have any languages to remove.***`);
}
await account.updateOne({ $pull: { 'additional.langs': args[0].split('-')[1] } });
return message.channel.createMessage(`***${this.client.util.emojis.SUCCESS} Removed language code ${args[0]} from profile.***`);
await account.updateOne({ $pull: { 'additional.langs': ctx.args[0].split('-')[1] } });
return ctx.uniCreateMessage(`***${this.client.util.emojis.SUCCESS} Removed language code ${ctx.args[0]} from profile.***`);
}
return message.channel.createMessage(`***${this.client.util.emojis.ERROR} Invalid data code.***`);
return ctx.uniCreateMessage(`***${this.client.util.emojis.ERROR} Invalid data code.***`);
}
}

View File

@ -1,5 +1,4 @@
import { Message } from 'eris';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
export default class DelMerchant extends Command {
constructor(client: Client) {
@ -13,10 +12,10 @@ export default class DelMerchant extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
const merchant = await this.client.db.mongo.Merchant.findOne({ key: args[0] });
if (!merchant) return this.error(message.channel, 'Merchant specified does not exist.');
return this.success(message.channel, `Deleted merchant \`${merchant._id}\`.`);
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
const merchant = await this.client.db.mongo.Merchant.findOne({ key: ctx.args[0] });
if (!merchant) return this.error(ctx.message.channel, 'Merchant specified does not exist.');
return this.success(ctx.message.channel, `Deleted merchant \`${merchant._id}\`.`);
}
}

View File

@ -1,5 +1,4 @@
import { Message } from 'eris';
import { Command, Client } from '../class';
import { Command, CmdContext, Client } from '../class';
export default class DelNote extends Command {
constructor(client: Client) {
@ -12,11 +11,11 @@ export default class DelNote extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
const note = await this.client.db.mongo.Note.findOne({ _id: args[0] }).lean().exec().catch(() => {});
if (!note) return this.error(message.channel, 'Could not locate that note.');
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
const note = await this.client.db.mongo.Note.findOne({ _id: ctx.args[0] }).lean().exec().catch(() => {});
if (!note) return this.error(ctx.message.channel, 'Could not locate that note.');
await this.client.db.mongo.Note.deleteOne({ _id: note._id });
return this.success(message.channel, `Note # \`${note._id}\` has been deleted.`);
return this.success(ctx.message.channel, `Note # \`${note._id}\` has been deleted.`);
}
}

View File

@ -1,5 +1,4 @@
import { Message } from 'eris';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
export default class DeletePromoCode extends Command {
constructor(client: Client) {
@ -13,13 +12,13 @@ export default class DeletePromoCode extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
try {
await this.client.stripe.promotionCodes.retrieve(args[0]);
await this.client.db.mongo.Promo.deleteOne({ pID: args[0] }).lean().exec();
await this.client.stripe.promotionCodes.retrieve(ctx.args[0]);
await this.client.db.mongo.Promo.deleteOne({ pID: ctx.args[0] }).lean().exec();
} catch (err) {
return this.error(message.channel, 'Promotional API ID doesn\'t exist.');
return this.error(ctx.message.channel, 'Promotional API ID doesn\'t exist.');
}
}
}

View File

@ -1,5 +1,4 @@
import { Message } from 'eris';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
export default class DelRank extends Command {
constructor(client: Client) {
@ -12,15 +11,15 @@ export default class DelRank extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
const role = this.client.util.resolveRole(args[0], this.mainGuild);
if (!role) return this.error(message.channel, 'The role you specified doesn\'t appear to exist.');
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
const role = this.client.util.resolveRole(ctx.args[0], this.mainGuild);
if (!role) return this.error(ctx.message.channel, 'The role you specified doesn\'t appear to exist.');
const check = await this.client.db.mongo.Rank.findOne({ roleID: role.id });
if (!check) return this.error(message.channel, 'The entry doesn\'t appear to exist.');
if (!check) return this.error(ctx.message.channel, 'The entry doesn\'t appear to exist.');
await this.client.db.mongo.Rank.deleteOne({ roleID: role.id });
return this.success(message.channel, `Role ${role.name} is no longer self-assignable.`);
return this.success(ctx.message.channel, `Role ${role.name} is no longer self-assignable.`);
}
}

View File

@ -1,5 +1,4 @@
import { Message } from 'eris';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
export default class DelRedirect extends Command {
constructor(client: Client) {
@ -12,11 +11,11 @@ export default class DelRedirect extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
const check = await this.client.db.mongo.Redirect.findOne({ key: args[0].toLowerCase() });
if (!check) return this.error(message.channel, `Redirect key ${args[0].toLowerCase()} doesn't exist.`);
await this.client.db.mongo.Redirect.deleteOne({ key: args[0].toLowerCase() });
return this.success(message.channel, `Deleted redirect https://loc.sh/${args[0].toLowerCase()}.`);
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
const check = await this.client.db.mongo.Redirect.findOne({ key: ctx.args[0].toLowerCase() });
if (!check) return this.error(ctx.message.channel, `Redirect key ${ctx.args[0].toLowerCase()} doesn't exist.`);
await this.client.db.mongo.Redirect.deleteOne({ key: ctx.args[0].toLowerCase() });
return this.success(ctx.message.channel, `Deleted redirect https://loc.sh/${ctx.args[0].toLowerCase()}.`);
}
}

View File

@ -1,6 +1,6 @@
import { Message, EmbedOptions } from 'eris';
import { EmbedOptions } from 'eris';
import axios, { AxiosResponse } from 'axios';
import { Client, Command, RichEmbed } from '../class';
import { Client, CmdContext, Command, RichEmbed } from '../class';
export default class DJS extends Command {
constructor(client: Client) {
@ -13,21 +13,21 @@ export default class DJS extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
let res: AxiosResponse<EmbedOptions>;
try {
res = await axios.get(`https://djsdocs.sorta.moe/v2/embed?src=master&q=${args[0]}`);
res = await axios.get(`https://djsdocs.sorta.moe/v2/embed?src=master&q=${ctx.args[0]}`);
} catch (err) {
return this.error(message.channel, 'Please try again later, something unexpected happened.');
return this.error(ctx.message.channel, 'Please try again later, something unexpected happened.');
}
if (!res.data) return this.error(message.channel, 'Could not find information. Try something else.');
if (!res.data) return this.error(ctx.message.channel, 'Could not find information. Try something else.');
const embed = new RichEmbed(res.data);
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setTimestamp();
return message.channel.createMessage({ embed });
return ctx.uniCreateMessage({ embed });
}
}

View File

@ -1,6 +1,6 @@
import { Message, EmbedOptions } from 'eris';
import { EmbedOptions } from 'eris';
import axios, { AxiosResponse } from 'axios';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
export default class Eris extends Command {
constructor(client: Client) {
@ -13,17 +13,17 @@ export default class Eris extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
let res: AxiosResponse<{embed: EmbedOptions}>;
try {
res = await axios.get('https://erisdocs.cloud.libraryofcode.org/docs', { params: { search: args[0] } });
res = await axios.get('https://erisdocs.cloud.libraryofcode.org/docs', { params: { search: ctx.args[0] } });
} catch (err) {
if (err.code === 404) return this.error(message.channel, 'Could not find information. Try something else.');
return this.error(message.channel, 'Please try again later, something unexpected happened.');
if (err.code === 404) return this.error(ctx.message.channel, 'Could not find information. Try something else.');
return this.error(ctx.message.channel, 'Please try again later, something unexpected happened.');
}
return message.channel.createMessage(res.data);
return ctx.uniCreateMessage(res.data);
}
}

View File

@ -1,7 +1,7 @@
import axios from 'axios';
import { inspect } from 'util';
import { Message } from 'eris';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
export default class Eval extends Command {
constructor(client: Client) {
@ -14,19 +14,20 @@ export default class Eval extends Command {
this.guildOnly = false;
}
public async run(message: Message, args: string[]) {
const evalMessage = message.content.slice(this.client.config.prefix.length).trim().split(' ').slice(1);
public async run(ctx: CmdContext) {
if (['278620217221971968', '239261547959025665'].includes(ctx.message.author.id) === false) return this.error(ctx.message.channel, 'Permission denied.');
const evalMessage = ctx.message.content.slice(this.client.config.prefix.length).trim().split(' ').slice(1);
let evalString = evalMessage.join(' ').trim();
let evaled: any;
let depth = 0;
if (args[0] && args[0].startsWith('-d')) {
depth = Number(args[0].replace('-d', ''));
if (ctx.args[0] && ctx.args[0].startsWith('-d')) {
depth = Number(ctx.args[0].replace('-d', ''));
if (!depth || depth < 0) depth = 0;
const index = evalMessage.findIndex((v) => v.startsWith('-d')) + 1;
evalString = evalMessage.slice(index).join(' ').trim();
}
if (args[0] === '-a') {
if (ctx.args[0] === '-a') {
const index = evalMessage.findIndex((v) => v === '-a') + 1;
evalString = `(async () => { ${evalMessage.slice(index).join(' ').trim()} })()`;
}
@ -53,12 +54,12 @@ export default class Eval extends Command {
if (display[5]) {
try {
const { data } = await axios.post('https://snippets.cloud.libraryofcode.org/documents', display.join(''));
return this.success(message.channel, `Your evaluation evaled can be found on https://snippets.cloud.libraryofcode.org/${data.key}`);
return this.success(ctx.message.channel, `Your evaluation evaled can be found on https://snippets.cloud.libraryofcode.org/${data.key}`);
} catch (error) {
return this.error(message.channel, `${error}`);
return this.error(ctx.message.channel, `${error}`);
}
}
return display.forEach((m) => message.channel.createMessage(`\`\`\`js\n${m}\n\`\`\``));
return display.forEach((m) => ctx.message.channel.createMessage(`\`\`\`js\n${m}\n\`\`\``));
}
}

View File

@ -1,6 +1,6 @@
import { createPaginationEmbed } from 'eris-pagination';
import { Message } from 'eris';
import { Client, Command, RichEmbed } from '../class';
import { Client, CmdContext, Command, RichEmbed } from '../class';
export default class Help extends Command {
constructor(client: Client) {
@ -13,10 +13,10 @@ export default class Help extends Command {
this.guildOnly = true;
}
public async run(message: Message, args: string[]) {
if (args.length > 0) {
const resolved = await this.client.util.resolveCommand(args, message);
if (!resolved) return this.error(message.channel, 'The command you provided doesn\'t exist.');
public async run(ctx: CmdContext) {
if (ctx.args.length > 0) {
const resolved = await this.client.util.resolveCommand(ctx.args, ctx.message);
if (!resolved) return this.error(ctx.message.channel, 'The command you provided doesn\'t exist.');
const { cmd } = resolved;
const embed = new RichEmbed();
const subcommands = cmd.subcommands.size ? `\n**Subcommands:** ${cmd.subcommands.map((s) => `${cmd.name} ${s.name}`).join(', ')}` : '';
@ -64,12 +64,12 @@ export default class Help extends Command {
}
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setTimestamp();
return message.channel.createMessage({ embed });
return ctx.message.channel.createMessage({ embed });
}
const cmdList: Command[] = [];
this.client.commands.forEach((c) => {
if (c.permissions !== 0 && c.guildOnly) {
const check = c.checkCustomPermissions(message.member, c.permissions);
const check = c.checkCustomPermissions(ctx.message.member, c.permissions);
if (!check) return;
}
cmdList.push(c);
@ -115,7 +115,7 @@ export default class Help extends Command {
splitCmd.forEach((c) => embed.addField(c.name, c.value, c.inline));
return cmdPages.push(embed);
});
if (cmdPages.length === 1) return message.channel.createMessage({ embed: cmdPages[0] });
return createPaginationEmbed(message, cmdPages);
if (cmdPages.length === 1) return ctx.message.channel.createMessage({ embed: cmdPages[0] });
return createPaginationEmbed(ctx.message, cmdPages);
}
}

View File

@ -1,6 +1,6 @@
import { Message } from 'eris';
import { totalmem } from 'os';
import { Client, Command, RichEmbed } from '../class';
import { Client, CmdContext, Command, RichEmbed } from '../class';
// eslint-disable-next-line import/no-relative-packages
import { version as tsVersion } from '../../node_modules/typescript/package.json';
@ -14,12 +14,12 @@ export default class Info extends Command {
this.enabled = true;
}
public async run(message: Message) {
public async run(ctx: CmdContext) {
const embed = new RichEmbed();
embed.setTitle('Information');
embed.setThumbnail(this.client.user.avatarURL);
embed.setDescription(`*See \`${this.client.config.prefix}sysinfo\` for more information on libraries used by this application.*`);
embed.addField('Developers', 'Library of Code sp-us | Dept. of Engineering', true);
embed.addField('Developers', 'Library of Code | Dept. of Engineering & other contributors', true);
embed.addField('Version', 'Rolling Release', true);
embed.addField('Language(s)', '<:TypeScript:703451285789343774> TypeScript', true);
embed.addField('Runtime', `Node (${process.version})`, true);
@ -30,6 +30,6 @@ export default class Info extends Command {
embed.addField('Commit', `[${await this.client.util.exec('git rev-parse --short HEAD')}](${await this.client.util.exec('git rev-parse HEAD')})`, true);
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setTimestamp();
message.channel.createMessage({ embed });
return ctx.uniCreateMessage({ embed });
}
}

View File

@ -1,8 +1,7 @@
/* eslint-disable no-continue */
/* eslint-disable default-case */
import { Message } from 'eris';
import { Client, Command, RichEmbed } from '../class';
import { getTotalMessageCount } from '../intervals/score';
import { Client, CmdContext, Command, RichEmbed } from '../class';
import { getTotalMessageCount } from '../functions/calculateReport';
import Inquiry_Remove from './inquiry_rm';
@ -19,15 +18,15 @@ export default class Inquiry extends Command {
this.subcmds = [Inquiry_Remove];
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
const inquiry = await this.client.db.mongo.Inquiry.findOne({ iid: args[0] });
if (!inquiry) return this.error(message.channel, 'Could not locate Inquiry information.');
const inquiry = await this.client.db.mongo.Inquiry.findOne({ iid: ctx.args[0] });
if (!inquiry) return this.error(ctx.message.channel, 'Could not locate Inquiry information.');
const currentReport = await this.client.db.mongo.Score.findOne({ userID: inquiry.userID });
if (!currentReport) return this.error(message.channel, 'Could not find Community Report for this user.');
if (!currentReport) return this.error(ctx.message.channel, 'Could not find Community Report for this user.');
const member = this.client.util.resolveMember(inquiry.userID, this.mainGuild);
if (!member) return this.error(message.channel, 'Could not locate member.');
if (!member) return this.error(ctx.message.channel, 'Could not locate member.');
const { report } = inquiry;
// if (!report) return this.error(message.channel, 'Could not find inquiry information.');
@ -93,6 +92,6 @@ export default class Inquiry extends Command {
}
embed.setTimestamp();
embed.setFooter('Inquiry performed on', this.client.user.avatarURL);
return message.channel.createMessage({ embed });
return ctx.uniCreateMessage({ embed });
}
}

View File

@ -1,7 +1,7 @@
import { Message, TextChannel } from 'eris';
import { TextChannel } from 'eris';
import axios from 'axios';
import { apply as Apply } from '.';
import { Client, Command, RichEmbed } from '../class';
import { Client, CmdContext, Command, RichEmbed } from '../class';
export default class Inquiry_Remove extends Command {
public applyCommand: Apply;
@ -17,19 +17,19 @@ export default class Inquiry_Remove extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
const inquiry = await this.client.db.mongo.Inquiry.findOne({ iid: args[0] });
if (!inquiry) return this.error(message.channel, 'Unable to find Inquiry.');
const inquiry = await this.client.db.mongo.Inquiry.findOne({ iid: ctx.args[0] });
if (!inquiry) return this.error(ctx.message.channel, 'Unable to find Inquiry.');
const member = this.client.util.resolveMember(inquiry.userID, this.mainGuild);
if (!member) return this.error(message.channel, 'Unable to locate member.');
if (!member) return this.error(ctx.message.channel, 'Unable to locate member.');
const report = await this.client.db.mongo.Score.findOne({ userID: member.id });
if (!report) return this.error(message.channel, 'Unable to locate Community Report.');
if (!report) return this.error(ctx.message.channel, 'Unable to locate Community Report.');
if (inquiry.type !== 0) return this.error(message.channel, 'You can only remove Hard Inquiries.');
if (inquiry.type !== 0) return this.error(ctx.message.channel, 'You can only remove Hard Inquiries.');
await this.client.db.mongo.Inquiry.deleteOne({ iid: args[0] });
await this.client.db.mongo.Inquiry.deleteOne({ iid: ctx.args[0] });
const embed = new RichEmbed();
embed.setTitle('Inquiry - Removed');
@ -46,7 +46,7 @@ export default class Inquiry_Remove extends Command {
url: `https://eds.libraryofcode.org/dec/${inquiry.iid}?auth=${this.client.config.internalKey}`,
});
} catch (e) {
this.error(message.channel, `An error occurred while changing EDS data: ${e}\n*(This does not mean that the operation failed.)*`);
this.error(ctx.message.channel, `An error occurred while changing EDS data: ${e}\n*(This does not mean that the operation failed.)*`);
}
const log = <TextChannel> this.client.guilds.get(this.client.config.guildID).channels.get('611584771356622849');
@ -57,6 +57,6 @@ export default class Inquiry_Remove extends Command {
chan.createMessage({ embed }).catch(() => {});
}
return this.success(message.channel, 'Inquiry successfully deleted.');
return this.success(ctx.message.channel, 'Inquiry successfully deleted.');
}
}

View File

@ -1,5 +1,4 @@
import { Message } from 'eris';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
import Judgement_Add from './judgement_add';
import Judgement_Delete from './judgement_delete';
@ -16,7 +15,7 @@ export default class Judgement extends Command {
this.subcmds = [Judgement_Add, Judgement_Delete];
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
}
}

View File

@ -1,7 +1,7 @@
import moment, { unitOfTime } from 'moment';
import { nanoid } from 'nanoid';
import { Message, TextChannel } from 'eris';
import { Client, Command, RichEmbed } from '../class';
import { TextChannel } from 'eris';
import { Client, CmdContext, Command, RichEmbed } from '../class';
export default class Judgement_Add extends Command {
constructor(client: Client) {
@ -14,24 +14,24 @@ export default class Judgement_Add extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, ['judgement', 'add']);
if (args.length < 4) return this.client.commands.get('help').run(message, ['judgement', 'add']);
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
if (ctx.args.length < 4) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
const member = this.client.util.resolveMember(args[0], this.mainGuild);
if (!member) return this.error(message.channel, 'Unable to locate member.');
const staff = await this.client.db.mongo.Staff.findOne({ userID: message.author.id }).lean().exec();
if (!staff) return this.error(message.channel, 'Unable to locate Staff information.');
const member = this.client.util.resolveMember(ctx.args[0], this.mainGuild);
if (!member) return this.error(ctx.message.channel, 'Unable to locate member.');
const staff = await this.client.db.mongo.Staff.findOne({ userID: ctx.message.author.id }).lean().exec();
if (!staff) return this.error(ctx.message.channel, 'Unable to locate Staff information.');
if (Number.isNaN(Number(args[1]))) return this.error(message.channel, 'Severity must be a number.');
if (Number(args[1]) < 0 || Number(args[1]) > 2) return this.error(message.channel, 'Severity must be greater than -1 and less than 3.');
if (Number.isNaN(Number(ctx.args[1]))) return this.error(ctx.message.channel, 'Severity must be a number.');
if (Number(ctx.args[1]) < 0 || Number(ctx.args[1]) > 2) return this.error(ctx.message.channel, 'Severity must be greater than -1 and less than 3.');
let momentMilliseconds: number;
const now: number = Date.now();
let date: Date;
if (args[2] !== '0') {
const lockLength = args[2].match(/[a-z]+|[^a-z]+/gi);
if (ctx.args[2] !== '0') {
const lockLength = ctx.args[2].match(/[a-z]+|[^a-z]+/gi);
const length = Number(lockLength[0]);
const unit = lockLength[1] as unitOfTime.Base;
momentMilliseconds = moment.duration(length, unit).asMilliseconds();
@ -43,16 +43,16 @@ export default class Judgement_Add extends Command {
const entry = new this.client.db.mongo.Judgement({
jid,
userID: member.user.id,
enteredBy: message.author.id,
severity: Number(args[1]),
enteredBy: ctx.message.author.id,
severity: Number(ctx.args[1]),
date: new Date(),
expires: date ?? undefined,
description: args.slice(3).join(' '),
description: ctx.args.slice(3).join(' '),
});
await entry.save();
let severity: string;
switch (Number(args[1])) {
switch (Number(ctx.args[1])) {
case 0:
severity = 'LOW';
break;
@ -71,7 +71,7 @@ export default class Judgement_Add extends Command {
embed.setTitle('Judgement - Creation');
embed.setDescription(entry.description);
embed.addField('Member', `${member.username}#${member.discriminator} (<@${member.id}>)`, true);
embed.addField('Entered by', `${message.author.username}, ${staff.pn.slice(0, 2).join(', ')}`, true);
embed.addField('Entered by', `${ctx.message.author.username}${staff?.isManager ? ' [k]' : ''}`, true);
embed.addField('Severity', severity, true);
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setTimestamp();
@ -82,6 +82,6 @@ export default class Judgement_Add extends Command {
}
log.createMessage({ embed });
return this.success(message.channel, `Judgement \`${jid}\` successfully recorded.`);
return this.success(ctx.message.channel, `Judgement \`${jid}\` successfully recorded.`);
}
}

View File

@ -1,5 +1,5 @@
import { Message, TextChannel } from 'eris';
import { Client, Command, RichEmbed } from '../class';
import { TextChannel } from 'eris';
import { Client, CmdContext, Command, RichEmbed } from '../class';
export default class Judgement_Delete extends Command {
constructor(client: Client) {
@ -13,15 +13,15 @@ export default class Judgement_Delete extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, ['judgement', 'delete']);
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
const member = this.client.util.resolveMember(args[0], this.mainGuild);
if (!member) return this.error(message.channel, 'Unable to locate member.');
const staff = await this.client.db.mongo.Staff.findOne({ userID: message.author.id }).lean().exec();
if (!staff) return this.error(message.channel, 'Unable to locate Staff information.');
const judgement = await this.client.db.mongo.Judgement.findOne({ jid: args[0] });
if (!judgement) return this.error(message.channel, 'Unable to locate judgement.');
const member = this.client.util.resolveMember(ctx.args[0], this.mainGuild);
if (!member) return this.error(ctx.message.channel, 'Unable to locate member.');
const staff = await this.client.db.mongo.Staff.findOne({ userID: ctx.message.author.id }).lean().exec();
if (!staff) return this.error(ctx.message.channel, 'Unable to locate Staff information.');
const judgement = await this.client.db.mongo.Judgement.findOne({ jid: ctx.args[0] });
if (!judgement) return this.error(ctx.message.channel, 'Unable to locate judgement.');
await judgement.delete();
@ -29,10 +29,10 @@ export default class Judgement_Delete extends Command {
const embed = new RichEmbed();
embed.setTitle('Judgement - Rescind');
embed.addField('Member', `${member.username}#${member.discriminator} (<@${member.id}>)`, true);
embed.addField('Rescinded by', `${message.author.username}, ${staff.pn.slice(0, 2).join(', ')}`, true);
embed.addField('Rescinded by', `${ctx.message.author.username}${staff?.isManager ? ' [k]' : ''}`, true);
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setTimestamp();
log.createMessage({ embed });
return this.success(message.channel, `Judgement \`${args[0]}\` successfully rescinded.`);
return this.success(ctx.message.channel, `Judgement \`${ctx.args[0]}\` successfully rescinded.`);
}
}

View File

@ -1,5 +1,5 @@
import { Member, Message } from 'eris';
import { Client, Command } from '../class';
import { Member } from 'eris';
import { Client, CmdContext, Command } from '../class';
export default class Kick extends Command {
constructor(client: Client) {
@ -12,22 +12,22 @@ export default class Kick extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
let user: Member = this.client.util.resolveMember(args[0], this.mainGuild);
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
let user: Member = this.client.util.resolveMember(ctx.args[0], this.mainGuild);
if (!user) {
try {
user = await this.client.getRESTGuildMember(this.mainGuild.id, args[0]);
user = await this.client.getRESTGuildMember(this.mainGuild.id, ctx.args[0]);
} catch {
return this.error(message.channel, 'Cannot find user.');
return this.error(ctx.message.channel, 'Cannot find user.');
}
}
if (user && !this.client.util.moderation.checkPermissions(user, message.member)) return this.error(message.channel, 'Permission Denied.');
message.delete();
if (user && !this.client.util.moderation.checkPermissions(user, ctx.message.member)) return this.error(ctx.message.channel, 'Permission Denied.');
ctx.message.delete();
const reason: string = args.slice(1).join(' ');
if (reason.length > 512) return this.error(message.channel, 'Kick reasons cannot be longer than 512 characters.');
await this.client.util.moderation.kick(user, message.member, reason);
return this.success(message.channel, `${user.username}#${user.discriminator} has been kicked.`);
const reason: string = ctx.args.slice(1).join(' ');
if (reason.length > 512) return this.error(ctx.message.channel, 'Kick reasons cannot be longer than 512 characters.');
await this.client.util.moderation.kick(user, ctx.message.member, reason);
return (await this.success(ctx.message.channel, `${user.username}#${user.discriminator} has been kicked.`)).delete();
}
}

View File

@ -1,6 +1,5 @@
import { Message } from 'eris';
import { createPaginationEmbed } from 'eris-pagination';
import { Client, Command, RichEmbed } from '../class';
import { Client, CmdContext, Command, RichEmbed } from '../class';
export default class DelRedirect extends Command {
constructor(client: Client) {
@ -13,10 +12,10 @@ export default class DelRedirect extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (args[0]) {
const redirects = await this.client.db.mongo.Redirect.find({ $or: [{ key: args[0].toLowerCase() }, { to: args[0].toLowerCase() }] });
if (redirects.length <= 0) return this.error(message.channel, 'Could not find an entry matching that query.');
public async run(ctx: CmdContext) {
if (ctx.args[0]) {
const redirects = await this.client.db.mongo.Redirect.find({ $or: [{ key: ctx.args[0].toLowerCase() }, { to: ctx.args[0].toLowerCase() }] });
if (redirects.length <= 0) return this.error(ctx.message.channel, 'Could not find an entry matching that query.');
const embed = new RichEmbed();
embed.setTitle('Redirect Information');
for (const redirect of redirects) {
@ -24,10 +23,10 @@ export default class DelRedirect extends Command {
}
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setTimestamp();
return message.channel.createMessage({ embed });
return ctx.message.channel.createMessage({ embed });
}
const redirects = await this.client.db.mongo.Redirect.find();
if (!redirects) return this.error(message.channel, 'No redirect links found.');
if (!redirects) return this.error(ctx.message.channel, 'No redirect links found.');
const redirectArray: [{ name: string, value: string }?] = [];
for (const redirect of redirects) {
redirectArray.push({ name: `${redirect.key} | visited ${redirect.visitedCount} times`, value: redirect.to });
@ -42,7 +41,7 @@ export default class DelRedirect extends Command {
split.forEach((c) => embed.addField(c.name, c.value));
return cmdPages.push(embed);
});
if (cmdPages.length === 1) return message.channel.createMessage({ embed: cmdPages[0] });
return createPaginationEmbed(message, cmdPages);
if (cmdPages.length === 1) return ctx.message.channel.createMessage({ embed: cmdPages[0] });
return createPaginationEmbed(ctx.message, cmdPages);
}
}

View File

@ -1,6 +1,5 @@
import { Message } from 'eris';
import stockInfo from 'stock-info';
import { Client, Command, RichEmbed } from '../class';
import { Client, CmdContext, Command, RichEmbed } from '../class';
export default class Market extends Command {
constructor(client: Client) {
@ -13,13 +12,13 @@ export default class Market extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
let stock: stockInfo.Stock;
try {
stock = await stockInfo.getSingleStockInfo(args[0]);
stock = await stockInfo.getSingleStockInfo(ctx.args[0]);
} catch (err) {
return this.error(message.channel, `Unable to fetch information for that ticker. | ${err}`);
return this.error(ctx.message.channel, `Unable to fetch information for that ticker. | ${err}`);
}
const embed = new RichEmbed();
@ -50,6 +49,6 @@ export default class Market extends Command {
embed.addField('Exchange', `${stock.fullExchangeName?.toUpperCase() ?? 'N/A'}`, true);
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setTimestamp();
return message.channel.createMessage({ embed });
return ctx.message.channel.createMessage({ embed });
}
}

View File

@ -1,6 +1,5 @@
import { Message } from 'eris';
import { createPaginationEmbed } from 'eris-pagination';
import { Client, Command, RichEmbed } from '../class';
import { Client, CmdContext, Command, RichEmbed } from '../class';
export default class Members extends Command {
constructor(client: Client) {
@ -13,9 +12,9 @@ export default class Members extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
public async run(ctx: CmdContext) {
await this.mainGuild.fetchAllMembers();
if (!args[0]) {
if (!ctx.args[0]) {
const embed = new RichEmbed();
const membersOnline = this.mainGuild.members.filter((member) => member.status === 'online');
const membersIdle = this.mainGuild.members.filter((member) => member.status === 'idle');
@ -29,13 +28,13 @@ export default class Members extends Command {
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setTimestamp();
return message.channel.createMessage({ embed });
return ctx.message.channel.createMessage({ embed });
}
const role = this.client.util.resolveRole(args.join(' '), this.mainGuild);
if (!role) return this.error(message.channel, 'The role you specified doesn\'t exist.');
const role = this.client.util.resolveRole(ctx.args.join(' '), this.mainGuild);
if (!role) return this.error(ctx.message.channel, 'The role you specified doesn\'t exist.');
const check = this.mainGuild.members.filter((m) => m.roles.includes(role.id));
if (!check || check?.length < 1) return this.error(message.channel, 'There are no members in this role.');
if (!check || check?.length < 1) return this.error(ctx.message.channel, 'There are no members in this role.');
const statusArray: string[] = [];
const membersOnline: string[] = [];
const membersIdle: string[] = [];
@ -77,7 +76,7 @@ export default class Members extends Command {
embed.setTimestamp();
return cmdPages.push(embed);
});
if (cmdPages.length === 1) return message.channel.createMessage({ embed: cmdPages[0] });
return createPaginationEmbed(message, cmdPages);
if (cmdPages.length === 1) return ctx.message.channel.createMessage({ embed: cmdPages[0] });
return createPaginationEmbed(ctx.message, cmdPages);
}
}

View File

@ -1,6 +1,5 @@
import moment, { unitOfTime } from 'moment';
import { Message } from 'eris';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
export default class Mute extends Command {
constructor(client: Client) {
@ -13,29 +12,29 @@ export default class Mute extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
const member = this.client.util.resolveMember(args[0], this.mainGuild);
if (!member) return this.error(message.channel, 'Cannot find user.');
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
const member = this.client.util.resolveMember(ctx.args[0], this.mainGuild);
if (!member) return this.error(ctx.message.channel, 'Cannot find user.');
try {
const res1 = await this.client.db.local.muted.get<boolean>(`muted-${member.id}`);
if (res1 || this.mainGuild.members.get(member.id).roles.includes('478373942638149643')) return this.error(message.channel, 'This user is already muted.');
if (res1 || this.mainGuild.members.get(member.id).roles.includes('478373942638149643')) return this.error(ctx.message.channel, 'This user is already muted.');
} catch {} // eslint-disable-line no-empty
if (member && !this.client.util.moderation.checkPermissions(member, message.member)) return this.error(message.channel, 'Permission Denied.');
message.delete();
if (member && !this.client.util.moderation.checkPermissions(member, ctx.message.member)) return this.error(ctx.message.channel, 'Permission Denied.');
ctx.message.delete();
let momentMilliseconds: number;
let reason: string;
if (args.length > 1) {
const lockLength = args[1].match(/[a-z]+|[^a-z]+/gi);
if (ctx.args.length > 1) {
const lockLength = ctx.args[1].match(/[a-z]+|[^a-z]+/gi);
const length = Number(lockLength[0]);
const unit = lockLength[1] as unitOfTime.Base;
momentMilliseconds = moment.duration(length, unit).asMilliseconds();
reason = momentMilliseconds ? args.slice(2).join(' ') : args.slice(1).join(' ');
if (reason.length > 512) return this.error(message.channel, 'Mute reasons cannot be longer than 512 characters.');
reason = momentMilliseconds ? ctx.args.slice(2).join(' ') : ctx.args.slice(1).join(' ');
if (reason.length > 512) return this.error(ctx.message.channel, 'Mute reasons cannot be longer than 512 characters.');
}
await this.client.util.moderation.mute(member.user, message.member, momentMilliseconds, reason);
return this.success(message.channel, `${member.user.username}#${member.user.discriminator} has been muted.`);
await this.client.util.moderation.mute(member.user, ctx.message.member, momentMilliseconds, reason);
return (await this.success(ctx.message.channel, `${member.user.username}#${member.user.discriminator} has been muted.`)).delete();
}
}

View File

@ -1,6 +1,6 @@
import { Message, Member, User } from 'eris';
import { Member, User } from 'eris';
import { createPaginationEmbed } from 'eris-pagination';
import { Command, Client, RichEmbed } from '../class';
import { Command, Client, RichEmbed, CmdContext } from '../class';
export default class Notes extends Command {
constructor(client: Client) {
@ -13,24 +13,24 @@ export default class Notes extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
let member: Member | User = this.client.util.resolveMember(args[0], this.mainGuild);
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
let member: Member | User = this.client.util.resolveMember(ctx.args[0], this.mainGuild);
if (!member) {
try {
member = await this.client.getRESTUser(args[0]);
member = await this.client.getRESTUser(ctx.args[0]);
} catch {
member = undefined;
}
}
if (!member) return this.error(message.channel, 'User specified could not be found.');
if (!member) return this.error(ctx.message.channel, 'User specified could not be found.');
const notes = await this.client.db.mongo.Note.find({ userID: member.id });
if (!notes || notes?.length < 1) return this.error(message.channel, 'No notes exist for this user.');
if (!notes || notes?.length < 1) return this.error(ctx.message.channel, 'No notes exist for this user.');
const noteArray: [{ name: string, value: string, inline: boolean }?] = [];
if (args[1] === 'comm' || args[1] === 'cs' || args[1] === 'edu') {
switch (args[1]) {
if (ctx.args[1] === 'comm' || ctx.args[1] === 'cs' || ctx.args[1] === 'edu') {
switch (ctx.args[1]) {
case 'comm':
for (const note of notes.sort((a, b) => b.date.getTime() - a.date.getTime()).filter((r) => r.category === 'comm')) {
noteArray.push({
@ -81,7 +81,7 @@ export default class Notes extends Command {
split.forEach((c) => embed.addField(c.name, c.value, c.inline));
return cmdPages.push(embed);
});
if (cmdPages.length === 1) return message.channel.createMessage({ embed: cmdPages[0] });
return createPaginationEmbed(message, cmdPages);
if (cmdPages.length === 1) return ctx.message.channel.createMessage({ embed: cmdPages[0] });
return createPaginationEmbed(ctx.message, cmdPages);
}
}

View File

@ -1,6 +1,5 @@
import { Message } from 'eris';
import axios from 'axios';
import { Client, Command, RichEmbed } from '../class';
import { Client, CmdContext, Command, RichEmbed } from '../class';
export default class NPM extends Command {
constructor(client: Client) {
@ -13,12 +12,12 @@ export default class NPM extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
const res = await axios.get(`https://registry.npmjs.com/${args[0]}`, { validateStatus: (_) => true });
const res = await axios.get(`https://registry.npmjs.com/${ctx.args[0]}`, { validateStatus: (_) => true });
if (res.status === 404) return this.error(message.channel, 'Could not find the library, try something else.');
if (res.status === 404) return this.error(ctx.message.channel, 'Could not find the library, try something else.');
const { data } = res;
@ -47,7 +46,7 @@ export default class NPM extends Command {
embed.setTimestamp();
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setAuthor('NPM', 'https://i.imgur.com/ErKf5Y0.png', 'https://www.npmjs.com/');
embed.setDescription(`[NPM](https://www.npmjs.com/package/${args[0]}) | [Homepage](${homepage}) | [Repository](${repository}) | [Bugs](${bugs})`);
embed.setDescription(`[NPM](https://www.npmjs.com/package/${ctx.args[0]}) | [Homepage](${homepage}) | [Repository](${repository}) | [Bugs](${bugs})`);
embed.addField('Name', name, true);
embed.addField('Latest version', version, true);
embed.addField('License', license, true);
@ -56,6 +55,6 @@ export default class NPM extends Command {
embed.addField('Creation Date', creation, true);
embed.addField('Modification Date', modification, true);
return message.channel.createMessage({ embed });
return ctx.uniCreateMessage({ embed });
}
}

View File

@ -1,3 +1,7 @@
/**
* Disabled to evaluate usefulness 2/11/23
*/
/* eslint-disable no-case-declarations */
/* eslint-disable no-continue */
/* eslint-disable no-await-in-loop */
@ -16,7 +20,7 @@ export default class Page extends Command {
this.usage = `${this.client.config.prefix}page <pager number> <pager code> [optional message]\n${this.client.config.prefix}page settings <type: email | phone> <options: [email: on/off | phone: on/off]>`;
this.aliases = ['p'];
this.permissions = 1;
this.enabled = true;
this.enabled = false;
this.guildOnly = true;
this.local = {
emergencyNumbers: ['#0', '#1', '#2', '#3'],

View File

@ -1,6 +1,5 @@
import { Message } from 'eris';
import axios, { AxiosResponse } from 'axios';
import { Client, Command, RichEmbed } from '../class';
import { Client, CmdContext, Command, RichEmbed } from '../class';
import PGP_Upload from './pgp_upload';
import PGP_Remove from './pgp_remove';
@ -38,11 +37,11 @@ export default class PGP extends Command {
this.subcmds = [PGP_Upload, PGP_Remove];
}
public async run(message: Message, args: string[]) {
const profile = await this.client.db.mongo.Member.findOne({ userID: args[0] || message.author.id });
if (!profile) return this.error(message.channel, 'Unable to find specified member\'s account.');
public async run(ctx: CmdContext) {
const profile = await this.client.db.mongo.Member.findOne({ userID: ctx.args[0] || ctx.message.author.id });
if (!profile) return this.error(ctx.message.channel, 'Unable to find specified member\'s account.');
const embed = new RichEmbed()
.setAuthor(`${message.author.username}#${message.author.discriminator}`, message.author.dynamicAvatarURL())
.setAuthor(`${ctx.message.author.username}#${ctx.message.author.discriminator}`, ctx.message.author.dynamicAvatarURL())
.setTitle('PGP Connections')
.setColor('#ffc63c')
.setDescription(`There are no PGP keys connected to your account. Use \`${this.client.config.prefix}pgp upload\` to add one.`)
@ -56,7 +55,7 @@ export default class PGP extends Command {
const { comment } = pgp.data;
if (comment) embed.addField('Comment', comment, true);
embed.addField('Created At', new Date(pgp.data.creationTime).toUTCString(), true);
} else this.client.commands.get('help').run(message, ['pgp', 'upload']);
message.channel.createMessage({ embed });
} else this.client.commands.get('help').run(ctx);
ctx.uniCreateMessage({ embed });
}
}

View File

@ -1,5 +1,4 @@
import { Message } from 'eris';
import { Command, Client } from '../class';
import { Command, Client, CmdContext } from '../class';
export default class PGP_Remove extends Command {
constructor(client: Client) {
@ -13,10 +12,10 @@ export default class PGP_Remove extends Command {
this.enabled = true;
}
public async run(message: Message) {
const profile = await this.client.db.mongo.Member.findOne({ userID: message.author.id });
if (!profile?.pgp) return this.error(message.channel, 'There are no PGP public keys connected to your account.');
public async run(ctx: CmdContext) {
const profile = await this.client.db.mongo.Member.findOne({ userID: ctx.message.author.id });
if (!profile?.pgp) return this.error(ctx.message.channel, 'There are no PGP public keys connected to your account.');
await profile.updateOne({ $unset: { pgp: '' } });
this.success(message.channel, 'Unlinked PGP public key from your account.');
this.success(ctx.message.channel, 'Unlinked PGP public key from your account.');
}
}

View File

@ -1,6 +1,5 @@
import { Message } from 'eris';
import axios, { AxiosResponse } from 'axios';
import { Command, Client } from '../class';
import { Command, Client, CmdContext } from '../class';
export default class PGP_Upload extends Command {
constructor(client: Client) {
@ -14,20 +13,20 @@ export default class PGP_Upload extends Command {
this.enabled = true;
}
public async run(message: Message) {
if (!message.attachments.length) return this.error(message.channel, 'Please upload your PGP public key as an attachment.');
if (!await this.client.db.mongo.Member.exists({ userID: message.author.id })) {
await this.client.db.mongo.Member.create({ userID: message.author.id });
public async run(ctx: CmdContext) {
if (!ctx.message.attachments.length) return this.error(ctx.message.channel, 'Please upload your PGP public key as an attachment.');
if (!await this.client.db.mongo.Member.exists({ userID: ctx.message.author.id })) {
await this.client.db.mongo.Member.create({ userID: ctx.message.author.id });
}
const [pgpAttachment] = message.attachments;
const [pgpAttachment] = ctx.message.attachments;
const pgpReq: AxiosResponse<string> = await axios(pgpAttachment.url);
const pgp = pgpReq.data;
try {
await axios.post('https://certapi.libraryofcode.org/pgp', pgp);
} catch {
return this.error(message.channel, 'Unable to parse your PGP public key.');
return this.error(ctx.message.channel, 'Unable to parse your PGP public key.');
}
await this.client.db.mongo.Member.updateOne({ userID: message.author.id }, { pgp });
this.success(message.channel, 'PGP public key successfully uploaded to your account.');
await this.client.db.mongo.Member.updateOne({ userID: ctx.message.author.id }, { pgp });
this.success(ctx.message.channel, 'PGP public key successfully uploaded to your account.');
}
}

View File

@ -1,5 +1,5 @@
import { Message } from 'eris';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
export default class Ping extends Command {
constructor(client: Client) {
@ -11,9 +11,9 @@ export default class Ping extends Command {
this.enabled = true;
}
public async run(message: Message) {
public async run(ctx: CmdContext) {
const clientStart: number = Date.now();
const msg: Message = await message.channel.createMessage('🏓 Pong!');
msg.edit(`🏓 Pong!\nClient: \`${Date.now() - clientStart}ms\`\nResponse: \`${msg.createdAt - message.createdAt}ms\``);
const msg: Message = await ctx.uniCreateMessage('🏓 Pong!');
msg.edit(`🏓 Pong!\nClient: \`${Date.now() - clientStart}ms\`\nResponse: \`${msg.createdAt - ctx.message.createdAt}ms\``);
}
}

View File

@ -1,5 +1,4 @@
import { Message } from 'eris';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
import Profile_Bio from './profile_bio';
import Profile_GitHub from './profile_github';
@ -16,11 +15,11 @@ export default class Profile extends Command {
this.subcmds = [Profile_Bio, Profile_GitHub, Profile_Gitlab];
}
public async run(message: Message) {
if (!await this.client.db.mongo.Member.exists({ userID: message.author.id })) {
await this.client.db.mongo.Member.create({ userID: message.author.id });
public async run(ctx: CmdContext) {
if (!await this.client.db.mongo.Member.exists({ userID: ctx.message.author.id })) {
await this.client.db.mongo.Member.create({ userID: ctx.message.author.id });
}
this.error(message.channel, `Please specify a valid option to change. Choose from \`github\`, \`bio\` and \`gitlab\`. You can view your profile with \`${this.client.config.prefix}whois\`.`);
this.error(ctx.message.channel, `Please specify a valid option to change. Choose from \`github\`, \`bio\` and \`gitlab\`. You can view your profile with \`${this.client.config.prefix}whois\`.`);
}
}

View File

@ -1,5 +1,4 @@
import { Message } from 'eris';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
export default class Profile_Bio extends Command {
constructor(client: Client) {
@ -11,29 +10,29 @@ export default class Profile_Bio extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!await this.client.db.mongo.Member.exists({ userID: message.author.id })) {
await this.client.db.mongo.Member.create({ userID: message.author.id });
public async run(ctx: CmdContext) {
if (!await this.client.db.mongo.Member.exists({ userID: ctx.message.author.id })) {
await this.client.db.mongo.Member.create({ userID: ctx.message.author.id });
}
const member = await this.client.db.mongo.Member.findOne({ userID: message.author.id });
const member = await this.client.db.mongo.Member.findOne({ userID: ctx.message.author.id });
if (!args[0]) {
if (!ctx.args[0]) {
await member.updateOne({
additional: {
...member.additional,
bio: null,
},
});
return message.addReaction('modSuccess:578750988907970567');
return ctx.message.addReaction('modSuccess:578750988907970567');
}
const bio = args.join(' ');
if (bio.length >= 256) return this.error(message.channel, 'Bio too long. It must be less than or equal to 256 characters.');
const bio = ctx.args.join(' ');
if (bio.length >= 256) return this.error(ctx.message.channel, 'Bio too long. It must be less than or equal to 256 characters.');
await member.updateOne({
additional: {
...member.additional,
bio,
},
});
return message.addReaction('modSuccess:578750988907970567');
return ctx.message.addReaction('modSuccess:578750988907970567');
}
}

View File

@ -1,5 +1,4 @@
import { Message } from 'eris';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
export default class Profile_GitHub extends Command {
constructor(client: Client) {
@ -11,19 +10,19 @@ export default class Profile_GitHub extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!await this.client.db.mongo.Member.exists({ userID: message.author.id })) {
await this.client.db.mongo.Member.create({ userID: message.author.id });
public async run(ctx: CmdContext) {
if (!await this.client.db.mongo.Member.exists({ userID: ctx.message.author.id })) {
await this.client.db.mongo.Member.create({ userID: ctx.message.author.id });
}
const member = await this.client.db.mongo.Member.findOne({ userID: message.author.id });
if (!args[0]) {
const member = await this.client.db.mongo.Member.findOne({ userID:ctx. message.author.id });
if (!ctx.args[0]) {
await member.updateOne({
additional: {
...member.additional,
github: null,
},
});
return message.addReaction('modSuccess:578750988907970567');
return ctx.message.addReaction('modSuccess:578750988907970567');
}
const urlRegex = new RegExp(
'^(https?:\\/\\/)?'
@ -34,14 +33,14 @@ export default class Profile_GitHub extends Command {
+ '(\\#[-a-z\\d_]*)?$',
'i',
);
if (!urlRegex.test(args[0]) || !args[0].startsWith('https://github.com/')) return this.error(message.channel, 'Invalid GitHub profile URL.');
if (!urlRegex.test(ctx.args[0]) || !ctx.args[0].startsWith('https://github.com/')) return this.error(ctx.message.channel, 'Invalid GitHub profile URL.');
await member.updateOne({
additional: {
...member.additional,
github: args[0],
github: ctx.args[0],
},
});
return message.addReaction('modSuccess:578750988907970567');
return ctx.message.addReaction('modSuccess:578750988907970567');
}
}

View File

@ -1,5 +1,4 @@
import { Message } from 'eris';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
export default class Profile_GitLab extends Command {
constructor(client: Client) {
@ -11,20 +10,20 @@ export default class Profile_GitLab extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!await this.client.db.mongo.Member.exists({ userID: message.author.id })) {
await this.client.db.mongo.Member.create({ userID: message.author.id });
public async run(ctx: CmdContext) {
if (!await this.client.db.mongo.Member.exists({ userID: ctx.message.author.id })) {
await this.client.db.mongo.Member.create({ userID: ctx.message.author.id });
}
if (!args[0]) return this.error(message.channel, 'No GitLab profile URL was provided.');
const member = await this.client.db.mongo.Member.findOne({ userID: message.author.id });
if (!args[0]) {
if (!ctx.args[0]) return this.error(ctx.message.channel, 'No GitLab profile URL was provided.');
const member = await this.client.db.mongo.Member.findOne({ userID: ctx.message.author.id });
if (!ctx.args[0]) {
await member.updateOne({
additional: {
...member.additional,
gitlab: null,
},
});
return message.addReaction('modSuccess:578750988907970567');
return ctx.message.addReaction('modSuccess:578750988907970567');
}
const urlRegex = new RegExp(
'^(https?:\\/\\/)?'
@ -35,14 +34,14 @@ export default class Profile_GitLab extends Command {
+ '(\\#[-a-z\\d_]*)?$',
'i',
);
if (!urlRegex.test(args[0])) return this.error(message.channel, 'Invalid GitLab profile URL.');
if (!urlRegex.test(ctx.args[0])) return this.error(ctx.message.channel, 'Invalid GitLab profile URL.');
await member.updateOne({
additional: {
...member.additional,
gitlab: args[0],
gitlab: ctx.args[0],
},
});
return message.addReaction('modSuccess:578750988907970567');
return ctx.message.addReaction('modSuccess:578750988907970567');
}
}

View File

@ -1,6 +1,6 @@
import { Message, Role } from 'eris';
import { Role } from 'eris';
import { createPaginationEmbed } from 'eris-pagination';
import { Client, Command, RichEmbed } from '../class';
import { Client, CmdContext, Command, RichEmbed } from '../class';
export default class Rank extends Command {
constructor(client: Client) {
@ -13,8 +13,8 @@ export default class Rank extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) {
public async run(ctx: CmdContext) {
if (!ctx.args[0]) {
const roles = await this.client.db.mongo.Rank.find();
const rankArray: [{ name: string, value: string }?] = [];
for (const rank of roles.sort((a, b) => a.name.localeCompare(b.name))) {
@ -29,7 +29,7 @@ export default class Rank extends Command {
perms = rolesArray.map((r) => this.mainGuild.roles.get(r.id)).sort((a, b) => b.position - a.position).map((r) => `<@&${r.id}>`).join(', ');
}
let hasRank = false;
if (message.member.roles.includes(rank.roleID)) hasRank = true;
if (ctx.message.member.roles.includes(rank.roleID)) hasRank = true;
rankArray.push({ name: rank.name, value: `${hasRank ? '*You have this role.*\n' : ''}__Description:__ ${rank.description}\n__Permissions:__ ${perms}` });
}
const ranksSplit = this.client.util.splitFields(rankArray);
@ -38,31 +38,31 @@ export default class Rank extends Command {
const embed = new RichEmbed();
embed.setTitle('Ranks');
embed.setDescription(`Use \`${this.client.config.prefix}rank <rank name>\` to join/leave the rank.`);
embed.setFooter(`Requested by: ${message.author.username}#${message.author.discriminator} | ${this.client.user.username}`, message.author.avatarURL);
embed.setFooter(`Requested by: ${ctx.message.author.username}#${ctx.message.author.discriminator} | ${this.client.user.username}`, ctx.message.author.avatarURL);
embed.setTimestamp();
split.forEach((c) => embed.addField(c.name, c.value));
return cmdPages.push(embed);
});
if (cmdPages.length === 1) return message.channel.createMessage({ embed: cmdPages[0] });
return createPaginationEmbed(message, cmdPages);
if (cmdPages.length === 1) return ctx.message.channel.createMessage({ embed: cmdPages[0] });
return createPaginationEmbed(ctx.message, cmdPages);
}
const role = this.client.util.resolveRole(args.join(' '), this.client.guilds.get(this.client.config.guildID));
if (!role) return this.error(message.channel, 'The role you specified doesn\'t exist.');
const role = this.client.util.resolveRole(ctx.args.join(' '), this.client.guilds.get(this.client.config.guildID));
if (!role) return this.error(ctx.message.channel, 'The role you specified doesn\'t exist.');
const entry = await this.client.db.mongo.Rank.findOne({ roleID: role.id }).lean().exec();
if (!entry) return this.error(message.channel, 'The rank you specified doesn\'t exist.');
if (!message.member.roles.includes(entry.roleID)) {
if (!entry) return this.error(ctx.message.channel, 'The rank you specified doesn\'t exist.');
if (!ctx.message.member.roles.includes(entry.roleID)) {
let permCheck: boolean;
if (entry.permissions.includes('0')) {
permCheck = true;
} else {
permCheck = entry.permissions.some((item) => message.member.roles.includes(item));
permCheck = entry.permissions.some((item) => ctx.message.member.roles.includes(item));
}
if (!permCheck) return this.error(message.channel, 'Permission denied.');
await message.member.addRole(entry.roleID, 'User self-assigned this role.');
this.success(message.channel, `You have self-assigned ${entry.name}.`);
} else if (message.member.roles.includes(entry.roleID)) {
await message.member.removeRole(entry.roleID, 'User has removed a self-assignable role.');
this.success(message.channel, `You have removed ${entry.name}.`);
if (!permCheck) return this.error(ctx.message.channel, 'Permission denied.');
await ctx.message.member.addRole(entry.roleID, 'User self-assigned this role.');
this.success(ctx.message.channel, `You have self-assigned ${entry.name}.`);
} else if (ctx.message.member.roles.includes(entry.roleID)) {
await ctx.message.member.removeRole(entry.roleID, 'User has removed a self-assignable role.');
this.success(ctx.message.channel, `You have removed ${entry.name}.`);
}
return null;
}

View File

@ -1,5 +1,5 @@
import { Message, Role as DRole } from 'eris';
import { Client, Command } from '../class';
import { Role as DRole } from 'eris';
import { Client, CmdContext, Command } from '../class';
export default class Role extends Command {
constructor(client: Client) {
@ -11,12 +11,12 @@ export default class Role extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (args.length < 2) return this.client.commands.get('help').run(message, [this.name]);
const member = this.client.util.resolveMember(args[0], this.mainGuild);
if (!member) return this.error(message.channel, 'Member not found');
public async run(ctx: CmdContext) {
if (ctx.args.length < 2) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
const member = this.client.util.resolveMember(ctx.args[0], this.mainGuild);
if (!member) return this.error(ctx.message.channel, 'Member not found');
// if (!this.client.util.moderation.checkPermissions(member, message.member)) return this.error(message.channel, 'Permission denied.');
const rolesList = args.slice(1).join(' ').split(', ');
const rolesList = ctx.args.slice(1).join(' ').split(', ');
const rolesToAdd = [];
const rolesToRemove = [];
let stop = false;
@ -27,7 +27,7 @@ export default class Role extends Command {
role = this.client.util.resolveRole(arg, this.mainGuild);
if (!role) {
stop = true;
return this.error(message.channel, `Role \`${arg}\` not found.`);
return this.error(ctx.message.channel, `Role \`${arg}\` not found.`);
}
if (member.roles.includes(role.id)) return rolesToRemove.push(role);
rolesToAdd.push(role);
@ -37,11 +37,11 @@ export default class Role extends Command {
role = this.client.util.resolveRole(arg.slice(1), this.mainGuild);
if (!role) {
stop = true;
return this.error(message.channel, `Role \`${arg.slice(1)}\` not found.`);
return this.error(ctx.message.channel, `Role \`${arg.slice(1)}\` not found.`);
}
if (member.roles.includes(role.id)) {
stop = true;
return this.error(message.channel, `You already have the role \`${role.name}\`.`);
return this.error(ctx.message.channel, `You already have the role \`${role.name}\`.`);
}
rolesToAdd.push(role);
continue;
@ -50,11 +50,11 @@ export default class Role extends Command {
role = this.client.util.resolveRole(arg.slice(1), this.mainGuild);
if (!role) {
stop = true;
return this.error(message.channel, `Role \`${arg.slice(1)}\` not found.`);
return this.error(ctx.message.channel, `Role \`${arg.slice(1)}\` not found.`);
}
if (!member.roles.includes(role.id)) {
stop = true;
return this.error(message.channel, `You don't have the role \`${role.name}\``);
return this.error(ctx.message.channel, `You don't have the role \`${role.name}\``);
}
rolesToRemove.push(role);
continue;
@ -62,8 +62,8 @@ export default class Role extends Command {
}
// eslint-disable-next-line
// if (stop) return;
rolesToAdd.forEach((role) => member.addRole(role.id));
rolesToRemove.forEach((role) => member.removeRole(role.id));
return this.success(message.channel, `Changed roles for ${member.username}#${member.discriminator}${rolesToAdd.length > 0 ? `, added \`${rolesToAdd.map((r) => r.name).join('`, `')}\`` : ''}${rolesToRemove.length > 0 ? `, removed \`${rolesToRemove.map((r) => r.name).join('`, `')}\`` : ''}`);
rolesToAdd.forEach((role) => member.addRole(role.id, `Actioneer: ${ctx.message.author.username}#${ctx.message.author.discriminator} (${ctx.message.author.id})`));
rolesToRemove.forEach((role) => member.removeRole(role.id, `Actioneer: ${ctx.message.author.username}#${ctx.message.author.discriminator} (${ctx.message.author.id})`));
return this.success(ctx.message.channel, `Changed roles for ${member.username}#${member.discriminator}${rolesToAdd.length > 0 ? `, added \`${rolesToAdd.map((r) => r.name).join('`, `')}\`` : ''}${rolesToRemove.length > 0 ? `, removed \`${rolesToRemove.map((r) => r.name).join('`, `')}\`` : ''}`);
}
}

View File

@ -1,6 +1,5 @@
import moment from 'moment';
import { Message } from 'eris';
import { Client, Command, RichEmbed } from '../class';
import { Client, CmdContext, Command, RichEmbed } from '../class';
export default class Roleinfo extends Command {
constructor(client: Client) {
@ -13,11 +12,11 @@ export default class Roleinfo extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
const role = this.client.util.resolveRole(args.join(' '), this.mainGuild);
if (!role) return this.error(message.channel, 'Could not find role.');
const role = this.client.util.resolveRole(ctx.args.join(' '), this.mainGuild);
if (!role) return this.error(ctx.message.channel, 'Could not find role.');
const perms = role.permissions;
const permsArray: string[] = [];
@ -48,6 +47,6 @@ export default class Roleinfo extends Command {
if (permsArray.length > 0) {
embed.addField('Permissions', permsArray.join(', '), true);
}
return message.channel.createMessage({ embed });
return ctx.uniCreateMessage({ embed });
}
}

View File

@ -1,6 +1,6 @@
import { Message, TextChannel } from 'eris';
import { TextChannel } from 'eris';
import { apply as Apply } from '.';
import { Client, Command, RichEmbed } from '../class';
import { Client, CmdContext, Command, RichEmbed } from '../class';
import SAA_Approve from './saa_approve';
import SAA_Decline from './saa_decline';
@ -21,34 +21,34 @@ export default class StaffAssistedApplication extends Command {
this.applyCommand = <Apply> this.client.commands.get('apply');
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
const member = this.client.util.resolveMember(args[0], this.mainGuild);
if (!member) return this.error(message.channel, 'Unable to locate member.');
const member = this.client.util.resolveMember(ctx.args[0], this.mainGuild);
if (!member) return this.error(ctx.message.channel, 'Unable to locate member.');
const report = await this.client.db.mongo.Score.findOne({ userID: member.id }).lean().exec();
if (!report) return this.error(message.channel, 'Unable to locate Community Report.');
const staff = await this.client.db.mongo.Staff.findOne({ userID: message.author.id }).lean().exec();
if (!staff) return this.error(message.channel, 'Unable to locate Staff information.');
if (!report) return this.error(ctx.message.channel, 'Unable to locate Community Report.');
const staff = await this.client.db.mongo.Staff.findOne({ userID: ctx.message.author.id }).lean().exec();
if (!staff) return this.error(ctx.message.channel, 'Unable to locate Staff information.');
const service = this.applyCommand.services.get(args[1]);
if (!service) return this.error(message.channel, 'Invalid service code.');
if (service.type !== 'HARD') return this.error(message.channel, 'SAAs cannot be ran for services that do not require a Hard Inquiry or pre-approvals.');
const service = this.applyCommand.services.get(ctx.args[1]);
if (!service) return this.error(ctx.message.channel, 'Invalid service code.');
if (service.type !== 'HARD') return this.error(ctx.message.channel, 'SAAs cannot be ran for services that do not require a Hard Inquiry or pre-approvals.');
const preValidationTest = await service.validation(member);
if (!preValidationTest) return this.error(message.channel, 'This member does not meet pre-validation requirements. A SAA cannot be executed.');
if (!preValidationTest) return this.error(ctx.message.channel, 'This member does not meet pre-validation requirements. A SAA cannot be executed.');
const loading = await this.loading(message.channel, 'Processing application with EDS. Please hold on a moment.');
const loading = await this.loading(ctx.message.channel, 'Processing application with EDS. Please hold on a moment.');
const application = await Apply.apply(this.client, service.url, member.id);
await (new this.client.db.mongo.SAA({
userID: member.id,
applicationID: application.id,
serviceCode: args[1],
serviceCode: ctx.args[1],
edsToken: application.token,
})).save();
await this.client.commands.get('score').run(message, [member.id, 'soft']);
await this.client.commands.get('score').run(new CmdContext(ctx.message, [member.id, 'soft']))
const edsEmbed = new RichEmbed();
edsEmbed.setTitle('Decision from EDS');
@ -72,7 +72,7 @@ export default class StaffAssistedApplication extends Command {
edsEmbed.addField('Application ID', application.id, true);
edsEmbed.setFooter(`${this.client.user.username} via Electronic Decision Service [EDS]`, this.client.user.avatarURL);
edsEmbed.setTimestamp();
await message.channel.createMessage({ embed: edsEmbed });
await ctx.message.channel.createMessage({ embed: edsEmbed });
const embed = new RichEmbed();
embed.setTitle('Information Panel');
@ -81,7 +81,7 @@ export default class StaffAssistedApplication extends Command {
embed.addField('Decline', `Run \`${this.client.config.prefix}saa decline ${application.id}\``);
embed.setFooter(`${this.client.user.username} | Staff-assisted Application via Electronic Decision Service [EDS]`, this.client.user.avatarURL);
embed.setTimestamp();
await message.channel.createMessage({ embed });
await ctx.message.channel.createMessage({ embed });
const notificationEmbed = new RichEmbed();
@ -89,9 +89,9 @@ export default class StaffAssistedApplication extends Command {
// eslint-disable-next-line no-useless-escape
notificationEmbed.addField('User', `${member.username}#${member.discriminator} | XXX-XX-${report.pin[2]}`);
notificationEmbed.addField('Decision', 'PROCESSING');
notificationEmbed.addField('Initiated by', `${message.author.username}, ${staff.pn.slice(0, 2).join(', ')} *on behalf of Library of Code sp-us*`);
notificationEmbed.addField('Initiated by', `${ctx.message.author.username}${staff?.isManager ? ' [k]' : ''} *on behalf of Library of Code sp-us*`);
notificationEmbed.addField('Application ID', application.id);
notificationEmbed.addField('Service Code', args[1]);
notificationEmbed.addField('Service Code', ctx.args[1]);
notificationEmbed.setFooter(this.client.user.username, this.client.user.avatarURL);
notificationEmbed.setTimestamp();
@ -100,7 +100,7 @@ export default class StaffAssistedApplication extends Command {
notificationEmbed.setDescription('*A Staff Assisted Application has been queued in your name. If you didn\'t request a SAA to be ran, please contact the Staff Team as soon as possible.\nYou should receive a decision soon, if you do not receive a decision within 72 hours please contact the Staff Team for further information.*');
const chan = await this.client.getDMChannel(member.id);
chan.createMessage({ embed: notificationEmbed }).then(() => this.success(message.channel, 'SAA successfully queued.')).catch(() => this.error(message.channel, 'Unable to deliver notification to user.'));
chan.createMessage({ embed: notificationEmbed }).then(() => this.success(ctx.message.channel, 'SAA successfully queued.')).catch(() => this.error(ctx.message.channel, 'Unable to deliver notification to user.'));
loading.delete().catch(() => {});
}

View File

@ -1,7 +1,7 @@
import { Message, TextChannel } from 'eris';
import { TextChannel } from 'eris';
import axios from 'axios';
import { apply as Apply } from '.';
import { Client, Command, RichEmbed } from '../class';
import { Client, CmdContext, Command, RichEmbed } from '../class';
export default class SAA_Approve extends Command {
public applyCommand: Apply;
@ -18,17 +18,17 @@ export default class SAA_Approve extends Command {
this.applyCommand = <Apply> this.client.commands.get('apply');
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
const saa = await this.client.db.mongo.SAA.findOne({ applicationID: args[0] }).lean().exec();
if (!saa) return this.error(message.channel, 'Unable to locate SAA.');
const saa = await this.client.db.mongo.SAA.findOne({ applicationID: ctx.args[0] }).lean().exec();
if (!saa) return this.error(ctx.message.channel, 'Unable to locate SAA.');
const member = this.client.util.resolveMember(saa.userID, this.mainGuild);
if (!member) return this.error(message.channel, 'Unable to locate member.');
if (!member) return this.error(ctx.message.channel, 'Unable to locate member.');
const report = await this.client.db.mongo.Score.findOne({ userID: saa.userID }).lean().exec();
if (!report) return this.error(message.channel, 'Unable to locate Community Report.');
const staff = await this.client.db.mongo.Staff.findOne({ userID: message.author.id }).lean().exec();
if (!staff) return this.error(message.channel, 'Unable to locate Staff information.');
if (!report) return this.error(ctx.message.channel, 'Unable to locate Community Report.');
const staff = await this.client.db.mongo.Staff.findOne({ userID: ctx.message.author.id }).lean().exec();
if (!staff) return this.error(ctx.message.channel, 'Unable to locate Staff information.');
await this.applyCommand.services.get(saa.serviceCode).func(this.client, member.id);
@ -38,7 +38,7 @@ export default class SAA_Approve extends Command {
// eslint-disable-next-line no-useless-escape
embed.addField('User', `${member.username}#${member.discriminator} | XXX-XX-${report.pin[2]}`);
embed.addField('Decision', 'APPROVED');
embed.addField('Underwriter', `${message.author.username}, ${staff.pn.slice(0, 2).join(', ')} *on behalf of Library of Code sp-us*`);
embed.addField('Underwriter', `${ctx.message.author.username}${staff?.isManager ? ' [k]' : ''} *on behalf of Library of Code sp-us*`);
embed.addField('Application ID', saa.applicationID);
embed.addField('Service Code', saa.serviceCode);
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
@ -49,7 +49,7 @@ export default class SAA_Approve extends Command {
embed.setDescription(`*A SAA has been ran in your name for a service, this embed contains the information about the result of that decision.*\n\nAccess link to the EDS recommendation for this decision: https://eds.libraryofcode.org/dec/${saa.edsToken}`);
const chan = await this.client.getDMChannel(saa.userID);
chan.createMessage({ embed }).then(() => this.success(message.channel, 'SAA successfully processed.')).catch(() => this.error(message.channel, 'Unable to deliver decision to user.'));
chan.createMessage({ embed }).then(() => this.success(ctx.message.channel, 'SAA successfully processed.')).catch(() => this.error(ctx.message.channel, 'Unable to deliver decision to user.'));
try {
await axios({
@ -58,7 +58,7 @@ export default class SAA_Approve extends Command {
data: { status: true },
});
} catch (e) {
this.error(message.channel, `An error occurred while changing EDS data: ${e}`);
this.error(ctx.message.channel, `An error occurred while changing EDS data: ${e}`);
}
await this.client.db.mongo.SAA.deleteOne({ _id: saa._id }).lean().exec();

View File

@ -1,6 +1,6 @@
import { Message, TextChannel } from 'eris';
import { TextChannel } from 'eris';
import { apply as Apply } from '.';
import { Client, Command, RichEmbed } from '../class';
import { Client, CmdContext, Command, RichEmbed } from '../class';
export default class SAA_Decline extends Command {
public applyCommand: Apply;
@ -17,17 +17,17 @@ export default class SAA_Decline extends Command {
this.applyCommand = <Apply> this.client.commands.get('apply');
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
const saa = await this.client.db.mongo.SAA.findOne({ applicationID: args[0] }).lean().exec();
if (!saa) return this.error(message.channel, 'Unable to locate SAA.');
const saa = await this.client.db.mongo.SAA.findOne({ applicationID: ctx.args[0] }).lean().exec();
if (!saa) return this.error(ctx.message.channel, 'Unable to locate SAA.');
const member = this.client.util.resolveMember(saa.userID, this.mainGuild);
if (!member) return this.error(message.channel, 'Unable to locate member.');
if (!member) return this.error(ctx.message.channel, 'Unable to locate member.');
const report = await this.client.db.mongo.Score.findOne({ userID: saa.userID }).lean().exec();
if (!report) return this.error(message.channel, 'Unable to locate Community Report.');
const staff = await this.client.db.mongo.Staff.findOne({ userID: message.author.id }).lean().exec();
if (!staff) return this.error(message.channel, 'Unable to locate Staff information.');
if (!report) return this.error(ctx.message.channel, 'Unable to locate Community Report.');
const staff = await this.client.db.mongo.Staff.findOne({ userID: ctx.message.author.id }).lean().exec();
if (!staff) return this.error(ctx.message.channel, 'Unable to locate Staff information.');
const embed = new RichEmbed();
embed.setTitle('Staff Assisted Application - Decision');
@ -35,7 +35,7 @@ export default class SAA_Decline extends Command {
// eslint-disable-next-line no-useless-escape
embed.addField('User', `${member.username}#${member.discriminator} | XXX-XX-${report.pin[2]}`);
embed.addField('Decision', 'DECLINED');
embed.addField('Underwriter', `${message.author.username}, ${staff.pn.slice(0, 2).join(', ')} *on behalf of Library of Code sp-us*`);
embed.addField('Underwriter', `${ctx.message.author.username}${staff?.isManager ? ' [k]' : ''} *on behalf of Library of Code sp-us*`);
embed.addField('Application ID', saa.applicationID);
embed.addField('Service Code', saa.serviceCode);
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
@ -46,7 +46,7 @@ export default class SAA_Decline extends Command {
embed.setDescription(`*A SAA has been ran in your name for a service, this embed contains the information about the result of that decision.*\n\nAccess link to the EDS recommendation for this decision: https://eds.libraryofcode.org/dec/${saa.edsToken}`);
const chan = await this.client.getDMChannel(saa.userID);
chan.createMessage({ embed }).then(() => this.success(message.channel, 'SAA successfully processed.')).catch(() => this.error(message.channel, 'Unable to deliver decision to user.'));
chan.createMessage({ embed }).then(() => this.success(ctx.message.channel, 'SAA successfully processed.')).catch(() => this.error(ctx.message.channel, 'Unable to deliver decision to user.'));
await this.client.db.mongo.SAA.deleteOne({ _id: saa._id }).lean().exec();
}

View File

@ -2,9 +2,9 @@
/* eslint-disable no-continue */
/* eslint-disable default-case */
import moment from 'moment';
import { Message, User } from 'eris';
import { Client, Command, RichEmbed } from '../class';
import { getTotalMessageCount } from '../intervals/score';
import { User } from 'eris';
import { Client, CmdContext, Command, RichEmbed } from '../class';
import { getTotalMessageCount } from '../functions/calculateReport';
import Score_Hist from './score_hist';
import Score_Notify from './score_notify';
import Score_Pref from './score_pref';
@ -22,38 +22,38 @@ export default class Score extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
public async run(ctx: CmdContext) {
let check = false;
let user: User;
if (!args[0] || !this.checkCustomPermissions(this.client.util.resolveMember(message.author.id, this.mainGuild), 4)) {
user = message.author;
if (!user) return this.error(message.channel, 'Member not found.');
if (!ctx.args[0] || !this.checkCustomPermissions(this.client.util.resolveMember(ctx.message.author.id, this.mainGuild), 4)) {
user = ctx.message.author;
if (!user) return this.error(ctx.message.channel, 'Member not found.');
await this.client.report.createInquiry(user.id, `${user.username} via Discord`, 1);
check = true;
} else {
user = this.client.util.resolveMember(args[0], this.mainGuild)?.user;
user = this.client.util.resolveMember(ctx.args[0], this.mainGuild)?.user;
if (!user) {
const sc = await this.client.db.mongo.Score.findOne({ pin: [Number(args[0].split('-')[0]), Number(args[0].split('-')[1]), Number(args[0].split('-')[2])] });
if (!sc) return this.error(message.channel, 'Member not found.');
const sc = await this.client.db.mongo.Score.findOne({ pin: [Number(ctx.args[0].split('-')[0]), Number(ctx.args[0].split('-')[1]), Number(ctx.args[0].split('-')[2])] });
if (!sc) return this.error(ctx.message.channel, 'Member not found.');
user = this.client.util.resolveMember(sc.userID, this.mainGuild)?.user;
}
if (args[1] !== 'soft' && args[1] !== 'hard') return this.error(message.channel, 'Invalid syntax. Report pull type must be "soft" or "hard".');
if (!user) return this.error(message.channel, 'Member not found.');
if (message.channel.type !== 0) return this.error(message.channel, 'Hard Inquiries must be initiated in a guild.');
if (args[1] === 'hard') {
if (args.length < 3) return this.client.commands.get('help').run(message, [this.name]);
const name = args.slice(2).join(' ').split(':')[0];
const reason = args.slice(2).join(' ').split(':')[1];
if (ctx.args[1] !== 'soft' && ctx.args[1] !== 'hard') return this.error(ctx.message.channel, 'Invalid syntax. Report pull type must be "soft" or "hard".');
if (!user) return this.error(ctx.message.channel, 'Member not found.');
if (ctx.message.channel.type !== 0) return this.error(ctx.message.channel, 'Hard Inquiries must be initiated in a guild.');
if (ctx.args[1] === 'hard') {
if (ctx.args.length < 3) return this.client.commands.get('help').run(ctx);
const name = ctx.args.slice(2).join(' ').split(':')[0];
const reason = ctx.args.slice(2).join(' ').split(':')[1];
const score = await this.client.db.mongo.Score.findOne({ userID: user.id });
if (!score) return this.error(message.channel, 'Score not calculated yet.');
if (score.locked) return this.error(message.channel, 'The score report you have requested has been locked.');
if (!score) return this.error(ctx.message.channel, 'Score not calculated yet.');
if (score.locked) return this.error(ctx.message.channel, 'The score report you have requested has been locked.');
await this.client.report.createInquiry(score.userID, name, 0, reason);
}
}
if (!user) return this.error(message.channel, 'Member not found.');
if (!user) return this.error(ctx.message.channel, 'Member not found.');
const score = await this.client.db.mongo.Score.findOne({ userID: user.id });
const inqs = await this.client.db.mongo.Inquiry.find({ userID: user.id, type: 0 });
if (!score) return this.error(message.channel, 'Community Report has not been generated yet.');
if (!score) return this.error(ctx.message.channel, 'Community Report has not been generated yet.');
let totalScore = '0';
let activityScore = '0';
let moderationScore = '0';
@ -164,7 +164,7 @@ export default class Score extends Command {
if (score.locked) {
embed.addField('Status', 'Score Report Locked');
}
if (score.pin?.length > 0 && message.channel.type === 1) {
if (score.pin?.length > 0 && ctx.message.channel.type === 1) {
embed.addField('PIN', score.pin.join('-'), true);
}
if (score.lastUpdate) {
@ -174,31 +174,31 @@ export default class Score extends Command {
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
}
// eslint-disable-next-line no-mixed-operators
if ((args[1] === 'hard' || args[1] === 'soft') && this.checkCustomPermissions(this.client.util.resolveMember(message.author.id, this.mainGuild), 4)) {
if ((ctx.args[1] === 'hard' || ctx.args[1] === 'soft') && this.checkCustomPermissions(this.client.util.resolveMember(ctx.message.author.id, this.mainGuild), 4)) {
if (score.pin?.length > 0) embed.addField('PIN', score.pin.join('-'), true);
if (args[1] === 'soft' && !check) {
if (ctx.args[1] === 'soft' && !check) {
let name = '';
// eslint-disable-next-line no-unreachable-loop
for (const role of this.client.util.resolveMember(message.author.id, this.mainGuild).roles.map((r) => this.mainGuild.roles.get(r)).sort((a, b) => b.position - a.position)) {
for (const role of this.client.util.resolveMember(ctx.message.author.id, this.mainGuild).roles.map((r) => this.mainGuild.roles.get(r)).sort((a, b) => b.position - a.position)) {
name = `Library of Code sp-us | ${role.name}`;
break;
}
await this.client.report.createInquiry(user.id, name, 1);
}
}
if (args[1] === 'hard' && this.checkCustomPermissions(this.client.util.resolveMember(message.author.id, this.mainGuild), 6)) {
await message.channel.createMessage({ embed });
await message.channel.createMessage('***===BEGIN ADDITIONAL INFORMATION===***');
await this.client.commands.get('score').subcommands.get('hist').run(message, [user.id]);
await this.client.commands.get('whois').run(message, [user.id]);
await this.client.commands.get('notes').run(message, [user.id]);
const whoisMessage = await message.channel.createMessage(`=whois ${user.id} --full`);
if (ctx.args[1] === 'hard' && this.checkCustomPermissions(this.client.util.resolveMember(ctx.message.author.id, this.mainGuild), 6)) {
await ctx.message.channel.createMessage({ embed });
await ctx.message.channel.createMessage('***===BEGIN ADDITIONAL INFORMATION===***');
await this.client.commands.get('score').subcommands.get('hist').run(new CmdContext(ctx.message, [user.id]));
await this.client.commands.get('whois').run(new CmdContext(ctx.message, [user.id]));
await this.client.commands.get('notes').run(new CmdContext(ctx.message, [user.id]));
const whoisMessage = await ctx. message.channel.createMessage(`=whois ${user.id} --full`);
await whoisMessage.delete();
const modlogsMessage = await message.channel.createMessage(`=modlogs ${user.id}`);
const modlogsMessage = await ctx.message.channel.createMessage(`=modlogs ${user.id}`);
await modlogsMessage.delete();
return message.channel.createMessage('***===END ADDITIONAL INFORMATION===***');
return ctx.message.channel.createMessage('***===END ADDITIONAL INFORMATION===***');
}
return message.channel?.createMessage({ embed });
return ctx.uniCreateMessage({ embed });
}
}

View File

@ -2,9 +2,9 @@
/* eslint-disable no-continue */
/* eslint-disable default-case */
import { median, mode, mean } from 'mathjs';
import { Message, User } from 'eris';
import { Client, Command, RichEmbed } from '../class';
import { getTotalMessageCount } from '../intervals/score';
import { User } from 'eris';
import { Client, CmdContext, Command, RichEmbed } from '../class';
import { getTotalMessageCount } from '../functions/calculateReport';
export default class Score_Hist extends Command {
constructor(client: Client) {
@ -17,33 +17,33 @@ export default class Score_Hist extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
public async run(ctx: CmdContext) {
let user: User;
if (!this.checkCustomPermissions(message.member, 4)) {
user = message.author;
if (!this.checkCustomPermissions(ctx.message.member, 4)) {
user = ctx.message.author;
await this.client.report.createInquiry(user.id, `${user.username}#${user.discriminator} VIA DISCORD - [HISTORICAL]`, 1);
} else if (!args[0]) {
user = message.author;
} else if (!ctx.args[0]) {
user = ctx.message.author;
await this.client.report.createInquiry(user.id, `${user.username}#${user.discriminator} VIA DISCORD - [HISTORICAL]`, 1);
} else {
user = this.client.util.resolveMember(args[0], this.mainGuild)?.user;
user = this.client.util.resolveMember(ctx.args[0], this.mainGuild)?.user;
if (!user) {
const sc = await this.client.db.mongo.Score.findOne({ pin: [Number(args[0].split('-')[0]), Number(args[0].split('-')[1]), Number(args[0].split('-')[2])] });
const sc = await this.client.db.mongo.Score.findOne({ pin: [Number(ctx.args[0].split('-')[0]), Number(ctx.args[0].split('-')[1]), Number(ctx.args[0].split('-')[2])] });
user = this.client.util.resolveMember(sc.userID, this.mainGuild)?.user;
let name = '';
// eslint-disable-next-line no-unreachable-loop
for (const role of this.client.util.resolveMember(message.author.id, this.mainGuild).roles.map((r) => this.mainGuild.roles.get(r)).sort((a, b) => b.position - a.position)) {
for (const role of this.client.util.resolveMember(ctx.message.author.id, this.mainGuild).roles.map((r) => this.mainGuild.roles.get(r)).sort((a, b) => b.position - a.position)) {
name = `Library of Code sp-us | ${role.name} - [HISTORICAL]`;
break;
}
await this.client.report.createInquiry(user.id, name, 1);
}
}
if (!user) return this.error(message.channel, 'Member not found.');
if (!user) return this.error(ctx.message.channel, 'Member not found.');
const hists = await this.client.db.mongo.ScoreHistorical.find({ userID: user.id }).lean().exec();
if (!hists) return this.error(message.channel, 'No history found.');
if (hists.length < 1) return this.error(message.channel, 'No history found.');
if (!hists) return this.error(ctx.message.channel, 'No history found.');
if (hists.length < 1) return this.error(ctx.message.channel, 'No history found.');
const totalArray: number[] = [];
const activityArray: number[] = [];
const moderationArray: number[] = [];
@ -125,6 +125,6 @@ export default class Score_Hist extends Command {
embed.setDescription(`__**Statistical Averages**__\n**CommScore™ Mean:** ${Number(totalMean).toFixed(2)} | **CommScore™ Mode:** ${Number(totalMode).toFixed(2)} | **CommScore™ Median:** ${Number(totalMedian).toFixed(2)}\n\n**Activity Mean:** ${Number(activityMean).toFixed(2)}\n**Roles Mean:** ${Number(roleMean).toFixed(2)}\n**Moderation Mean:** ${Number(moderationMean).toFixed(2)}\n**Cloud Services Mean:** ${Number(cloudServicesMean).toFixed(2)}\n**Other Mean:** ${Number(otherMean).toFixed(2)}\n**Misc Mean:** ${Number(miscMean).toFixed(2)}`);
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
return message.channel.createMessage({ embed });
return ctx.uniCreateMessage({ embed });
}
}

View File

@ -1,5 +1,4 @@
import { Message } from 'eris';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
export default class Score_Notify extends Command {
constructor(client: Client) {
@ -12,21 +11,21 @@ export default class Score_Notify extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
const user = message.author;
if (!user) return this.error(message.channel, 'Member not found.');
const score = await this.client.db.mongo.Score.findOne({ userID: message.author.id });
if (!score) return this.error(message.channel, 'Score not calculated yet.');
if (!score.notify) await this.client.db.mongo.Score.updateOne({ userID: message.author.id }, { $set: { notify: false } });
switch (args[0]) {
public async run(ctx: CmdContext) {
const user = ctx.message.author;
if (!user) return this.error(ctx.message.channel, 'Member not found.');
const score = await this.client.db.mongo.Score.findOne({ userID: ctx.message.author.id });
if (!score) return this.error(ctx.message.channel, 'Your Community Report has not been generated yet. Check back a little later.');
if (!score.notify) await this.client.db.mongo.Score.updateOne({ userID: ctx.message.author.id }, { $set: { notify: false } });
switch (ctx.args[0]) {
case 'on':
await this.client.db.mongo.Score.updateOne({ userID: message.author.id }, { $set: { notify: true } });
return this.success(message.channel, 'You will now be sent notifications whenever your score is hard-pulled.');
await this.client.db.mongo.Score.updateOne({ userID: ctx.message.author.id }, { $set: { notify: true } });
return this.success(ctx.message.channel, 'You will now be sent notifications whenever your score is hard-pulled.');
case 'off':
await this.client.db.mongo.Score.updateOne({ userID: message.author.id }, { $set: { notify: false } });
return this.success(message.channel, 'You will no longer be sent notifications when your score is hard-pulled.');
await this.client.db.mongo.Score.updateOne({ userID: ctx.message.author.id }, { $set: { notify: false } });
return this.success(ctx.message.channel, 'You will no longer be sent notifications when your score is hard-pulled.');
default:
return this.error(message.channel, 'Invalid option. Valid options are `on` and `off`.');
return this.error(ctx.message.channel, 'Invalid option. Valid options are `on` and `off`.');
}
}
}

View File

@ -1,5 +1,4 @@
import { Message } from 'eris';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
export default class Score_Pref extends Command {
constructor(client: Client) {
@ -12,20 +11,20 @@ export default class Score_Pref extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!message.author) return this.error(message.channel, 'Member not found.');
const score = await this.client.db.mongo.Score.findOne({ userID: message.author.id });
if (!score) return this.error(message.channel, 'Score not calculated yet.');
if (!score.locked) await this.client.db.mongo.Score.updateOne({ userID: message.author.id }, { $set: { locked: false } });
switch (args[0]) {
public async run(ctx: CmdContext) {
if (!ctx.message.author) return this.error(ctx.message.channel, 'Member not found.');
const score = await this.client.db.mongo.Score.findOne({ userID: ctx.message.author.id });
if (!score) return this.error(ctx.message.channel, 'Score not calculated yet.');
if (!score.locked) await this.client.db.mongo.Score.updateOne({ userID: ctx.message.author.id }, { $set: { locked: false } });
switch (ctx.args[0]) {
case 'lock':
await this.client.db.mongo.Score.updateOne({ userID: message.author.id }, { $set: { locked: true } });
return this.success(message.channel, 'Your report is now locked.');
await this.client.db.mongo.Score.updateOne({ userID: ctx.message.author.id }, { $set: { locked: true } });
return this.success(ctx.message.channel, 'Your report is now locked.');
case 'unlock':
await this.client.db.mongo.Score.updateOne({ userID: message.author.id }, { $set: { locked: false } });
return this.success(message.channel, 'Your report is now unlocked.');
await this.client.db.mongo.Score.updateOne({ userID: ctx.message.author.id }, { $set: { locked: false } });
return this.success(ctx.message.channel, 'Your report is now unlocked.');
default:
return this.error(message.channel, 'Invalid input');
return this.error(ctx.message.channel, 'Invalid input');
}
}
}

View File

@ -1,5 +1,4 @@
import { Message } from 'eris';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
export default class Setnick extends Command {
constructor(client: Client) {
@ -12,14 +11,14 @@ export default class Setnick extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
const member = this.client.util.resolveMember(args[0], this.mainGuild);
if (!member) return this.error(message.channel, 'Cannot find user.');
let nickname = args.slice(1).join(' ');
if (args.length === 1) nickname = null;
if (nickname?.length > 32) return this.error(message.channel, 'New nickname may not be more than 32 characters long.');
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
const member = this.client.util.resolveMember(ctx.args[0], this.mainGuild);
if (!member) return this.error(ctx.message.channel, 'Cannot find user.');
let nickname = ctx.args.slice(1).join(' ');
if (ctx.args.length === 1) nickname = null;
if (nickname?.length > 32) return this.error(ctx.message.channel, 'New nickname may not be more than 32 characters long.');
await member.edit({ nick: nickname });
return this.success(message.channel, `Updated the nickname of ${member.user.username}#${member.user.discriminator}.`);
return this.success(ctx.message.channel, `Updated the nickname of ${member.user.username}#${member.user.discriminator}.`);
}
}

View File

@ -1,3 +1,7 @@
/**
* Disabled command due to no use 2/13/23
*/
/* eslint-disable consistent-return */
import { Message } from 'eris';
import type { Channel } from 'ari-client';
@ -12,7 +16,7 @@ export default class SIP extends Command {
this.usage = `${this.client.config.prefix}sip <uri>`;
this.permissions = 1;
this.guildOnly = true;
this.enabled = true;
this.enabled = false;
}
public async run(message: Message, args: string[]) {

View File

@ -1,6 +1,5 @@
import { Message } from 'eris';
import { apply as Apply } from '.';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
import SSS_Create_Account from './sss_create_account';
import SSS_Password_Reset from './sss_password_reset';
@ -21,7 +20,7 @@ export default class StaffAccountSelfServ extends Command {
this.subcmds = [SSS_Create_Account, SSS_Password_Reset];
}
public async run(message: Message) {
return this.client.commands.get('help').run(message, [this.name]);
public async run(ctx: CmdContext) {
return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
}
}

View File

@ -1,6 +1,5 @@
import { Message } from 'eris';
import { apply as Apply } from '.';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
export default class SSS_Password_Reset extends Command {
public applyCommand: Apply;
@ -15,20 +14,20 @@ export default class SSS_Password_Reset extends Command {
this.enabled = true;
}
public async run(message: Message) {
public async run(ctx: CmdContext) {
try {
const staff = await this.client.db.mongo.Staff.findOne({ userID: message.author.id }).lean().exec();
if (!staff) return this.error(message.channel, 'Staff information not located.');
const staff = await this.client.db.mongo.Staff.findOne({ userID: ctx.message.author.id }).lean().exec();
if (!staff) return this.error(ctx.message.channel, 'Staff information not located.');
const passwordTicket = await this.client.util.authClient.createPasswordChangeTicket({
email: staff.emailAddress,
connection_id: 'con_T3ELEx2reigKMSlP',
});
const channel = await this.client.getDMChannel(message.author.id);
channel.createMessage(`__**Library of Code sp-us | Identity & Account Management**__\n\nPlease click the link below to reset your password.\n\n${passwordTicket.ticket}`).catch(() => this.error(message.channel, 'Unable to send you a DM.'));
return message.addReaction('modSuccess:578750988907970567');
const channel = await this.client.getDMChannel(ctx.message.author.id);
channel.createMessage(`__**Library of Code sp-us | Identity & Account Management**__\n\nPlease click the link below to reset your password.\n\n${passwordTicket.ticket}`).catch(() => this.error(ctx.message.channel, 'Unable to send you a DM.'));
return ctx.message.addReaction('modSuccess:578750988907970567');
} catch (err) {
return this.client.util.handleError(err, message, this);
return this.client.util.handleError(err, ctx.message, this);
}
}
}

View File

@ -1,5 +1,4 @@
import { Message } from 'eris';
import { Client, Command, RichEmbed } from '../class';
import { Client, CmdContext, Command, RichEmbed } from '../class';
export default class Stats extends Command {
constructor(client: Client) {
@ -12,7 +11,7 @@ export default class Stats extends Command {
this.enabled = true;
}
public async run(message: Message) {
public async run(ctx: CmdContext) {
const messages = await this.client.db.mongo.Stat.findOne({ name: 'messages' });
const commands = await this.client.db.mongo.Stat.findOne({ name: 'commands' });
const pages = await this.client.db.mongo.Stat.findOne({ name: 'pages' });
@ -28,6 +27,6 @@ export default class Stats extends Command {
embed.addField('Jobs Processed', `${(await this.client.queue.jobCounts()).completed}`, true);
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setTimestamp();
return message.channel.createMessage({ embed });
return ctx.uniCreateMessage({ embed });
}
}

View File

@ -1,9 +1,8 @@
/* eslint-disable import/no-relative-packages */
// ?e require('mongoose').connections[0].db.command({ buildInfo: 1 })
import { Message } from 'eris';
import mongoose from 'mongoose';
import { Client, Command, RichEmbed } from '../class';
import { Client, CmdContext, Command, RichEmbed } from '../class';
import { version as erisVersion } from '../../node_modules/eris/package.json';
import { version as mongooseVersion } from '../../node_modules/mongoose/package.json';
import { version as ariVersion } from '../../node_modules/ari-client/package.json';
@ -25,7 +24,7 @@ export default class SysInfo extends Command {
this.enabled = true;
}
public async run(message: Message) {
public async run(ctx: CmdContext) {
const embed = new RichEmbed();
embed.setTitle('System & Service Information');
embed.setDescription('__Format of Services__\n- {Server/Service Name} + {various server stats} | {Node Library Used for Communication w/ Server or Service}');
@ -46,6 +45,6 @@ export default class SysInfo extends Command {
embed.addField('Audio & Voice', `- [Google Cloud ML](https://cloud.google.com/text-to-speech) | [Google Cloud Node.js Text to Speech Synthesizer v${ttsVersion}](https://github.com/googleapis/nodejs-text-to-speech)\n - [FFMPEG](https://ffmpeg.org/) | Internal`, true);
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setTimestamp();
message.channel.createMessage({ embed });
ctx.uniCreateMessage({ embed });
}
}

View File

@ -1,7 +1,6 @@
import axios from 'axios';
import { v4 as uuid } from 'uuid';
import { Message } from 'eris';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
export default class TTS extends Command {
constructor(client: Client) {
@ -14,19 +13,19 @@ export default class TTS extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
if (args.length > 200) return this.error(message.channel, 'Cannot synthesize more than 200 characters.');
const msg = await this.loading(message.channel, 'Synthesizing...');
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
if (ctx.args.length > 200) return this.error(ctx.message.channel, 'Cannot synthesize more than 200 characters.');
const msg = await this.loading(ctx.message.channel, 'Synthesizing...');
const d = await axios({
method: 'GET',
url: `https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&q=${encodeURIComponent(args.join(' '))}&tl=en`,
url: `https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&q=${encodeURIComponent(ctx.args.join(' '))}&tl=en`,
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0',
},
responseType: 'arraybuffer',
});
msg.delete();
return message.channel.createMessage(undefined, { name: `${uuid()}.mp3`, file: d.data });
return ctx.message.channel.createMessage(undefined, { name: `${uuid()}.mp3`, file: d.data });
}
}

View File

@ -1,5 +1,5 @@
import { Message, User } from 'eris';
import { Client, Command } from '../class';
import { User } from 'eris';
import { Client, CmdContext, Command } from '../class';
export default class Unban extends Command {
constructor(client: Client) {
@ -12,22 +12,22 @@ export default class Unban extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
let user: User;
try {
user = await this.client.getRESTUser(args[0]);
user = await this.client.getRESTUser(ctx.args[0]);
} catch {
return this.error(message.channel, 'Could find find user.');
return this.error(ctx.message.channel, 'Could find find user.');
}
try {
await this.mainGuild.getBan(args[0]);
await this.mainGuild.getBan(ctx.args[0]);
} catch {
return this.error(message.channel, 'This user is not banned.');
return this.error(ctx.message.channel, 'This user is not banned.');
}
message.delete();
ctx.message.delete();
await this.client.util.moderation.unban(user.id, message.member, args.slice(1).join(' '));
return this.success(message.channel, `${user.username}#${user.discriminator} has been unbanned.`);
await this.client.util.moderation.unban(user.id, ctx.message.member, ctx.args.slice(1).join(' '));
return this.success(ctx.message.channel, `${user.username}#${user.discriminator} has been unbanned.`);
}
}

View File

@ -1,5 +1,4 @@
import { Message } from 'eris';
import { Client, Command } from '../class';
import { Client, CmdContext, Command } from '../class';
export default class Unmute extends Command {
constructor(client: Client) {
@ -12,19 +11,19 @@ export default class Unmute extends Command {
this.enabled = true;
}
public async run(message: Message, args: string[]) {
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
const member = this.client.util.resolveMember(args[0], this.mainGuild);
if (!member) return this.error(message.channel, 'Cannot find user.');
public async run(ctx: CmdContext) {
if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name]));
const member = this.client.util.resolveMember(ctx.args[0], this.mainGuild);
if (!member) return this.error(ctx.message.channel, 'Cannot find user.');
try {
const res1 = await this.client.db.local.muted.get<boolean>(`muted-${member.id}`);
if (!res1 || !this.mainGuild.members.get(member.id).roles.includes('478373942638149643')) return this.error(message.channel, 'This user is already unmuted.');
if (!res1 || !this.mainGuild.members.get(member.id).roles.includes('478373942638149643')) return this.error(ctx.message.channel, 'This user is already unmuted.');
} catch {} // eslint-disable-line no-empty
if (member && !this.client.util.moderation.checkPermissions(member, message.member)) return this.error(message.channel, 'Permission Denied.');
message.delete();
if (member && !this.client.util.moderation.checkPermissions(member, ctx.message.member)) return this.error(ctx.message.channel, 'Permission Denied.');
ctx.message.delete();
await this.client.util.moderation.unmute(member.user.id, message.member, args.slice(1).join(' '));
return this.success(message.channel, `${member.user.username}#${member.user.discriminator} has been unmuted.`);
await this.client.util.moderation.unmute(member.user.id, ctx.message.member, ctx.args.slice(1).join(' '));
return this.success(ctx.message.channel, `${member.user.username}#${member.user.discriminator} has been unmuted.`);
}
}

View File

@ -1,6 +1,5 @@
import { Message } from 'eris';
import axios, { AxiosResponse } from 'axios';
import { Client, Command, RichEmbed } from '../class';
import { Client, CmdContext, Command, RichEmbed } from '../class';
import X509_Upload from './x509_upload';
import X509_Remove from './x509_remove';
@ -57,11 +56,11 @@ export default class X509 extends Command {
this.subcmds = [X509_Upload, X509_Remove];
}
public async run(message: Message, args: string[]) {
const profile = await this.client.db.mongo.Member.findOne({ userID: args[0] || message.author.id });
if (!profile) return this.error(message.channel, 'Unable to find specified member\'s account.');
public async run(ctx: CmdContext) {
const profile = await this.client.db.mongo.Member.findOne({ userID: ctx.args[0] || ctx.message.author.id });
if (!profile) return this.error(ctx.message.channel, 'Unable to find specified member\'s account.');
const embed = new RichEmbed()
.setAuthor(`${message.author.username}#${message.author.discriminator}`, message.author.dynamicAvatarURL())
.setAuthor(`${ctx.message.author.username}#${ctx.message.author.discriminator}`, ctx.message.author.dynamicAvatarURL())
.setTitle('X.509 Connections')
.setColor('#ffc63c')
.setDescription(`There are no X.509 certificates connected to your account. Use \`${this.client.config.prefix}x509 upload\` to add one.`)
@ -78,7 +77,7 @@ export default class X509 extends Command {
embed.addField('Not After', new Date(x509.data.notAfter).toUTCString(), true);
if (x509.data.keyUsageAsText.length) embed.addField('Key Usages', x509.data.keyUsageAsText.join(', '), true);
if (x509.data.extendedKeyUsageAsText.length) embed.addField('Extended Key Usages', x509.data.extendedKeyUsageAsText.join(', '), true);
} else this.client.commands.get('help').run(message, ['x509', 'upload']);
message.channel.createMessage({ embed });
} else this.client.commands.get('help').run(new CmdContext(ctx.message, ['x509', 'upload']));
ctx.message.channel.createMessage({ embed });
}
}

View File

@ -1,5 +1,4 @@
import { Message } from 'eris';
import { Command, Client } from '../class';
import { Command, Client, CmdContext } from '../class';
export default class X509_Remove extends Command {
constructor(client: Client) {
@ -13,10 +12,10 @@ export default class X509_Remove extends Command {
this.enabled = true;
}
public async run(message: Message) {
const profile = await this.client.db.mongo.Member.findOne({ userID: message.author.id });
if (!profile?.x509) return this.error(message.channel, 'There are no X.509 certificates connected to your account.');
public async run(ctx: CmdContext) {
const profile = await this.client.db.mongo.Member.findOne({ userID: ctx.message.author.id });
if (!profile?.x509) return this.error(ctx.message.channel, 'There are no X.509 certificates connected to your account.');
await profile.updateOne({ $unset: { x509: '' } });
this.success(message.channel, 'Unlinked X.509 certificate from your account.');
this.success(ctx.message.channel, 'Unlinked X.509 certificate from your account.');
}
}

View File

@ -1,6 +1,5 @@
import { Message } from 'eris';
import axios, { AxiosResponse } from 'axios';
import { Command, Client } from '../class';
import { Command, Client, CmdContext } from '../class';
export default class X509_Upload extends Command {
constructor(client: Client) {
@ -14,20 +13,20 @@ export default class X509_Upload extends Command {
this.enabled = true;
}
public async run(message: Message) {
if (!message.attachments.length) return this.error(message.channel, 'Please upload your x509 certificate as an attachment.');
if (!await this.client.db.mongo.Member.exists({ userID: message.author.id })) {
await this.client.db.mongo.Member.create({ userID: message.author.id });
public async run(ctx: CmdContext) {
if (!ctx.message.attachments.length) return this.error(ctx.message.channel, 'Please upload your x509 certificate as an attachment.');
if (!await this.client.db.mongo.Member.exists({ userID: ctx.message.author.id })) {
await this.client.db.mongo.Member.create({ userID: ctx.message.author.id });
}
const [x509Attachment] = message.attachments;
const [x509Attachment] = ctx.message.attachments;
const x509Req: AxiosResponse<string> = await axios(x509Attachment.url);
const x509 = x509Req.data;
try {
await axios.post('https://certapi.libraryofcode.org/parse', x509);
} catch {
return this.error(message.channel, 'Unable to parse your x509 certificate.');
return this.error(ctx.message.channel, 'Unable to parse your x509 certificate.');
}
await this.client.db.mongo.Member.updateOne({ userID: message.author.id }, { x509 });
this.success(message.channel, 'x509 certificate successfully uploaded to your account.');
await this.client.db.mongo.Member.updateOne({ userID: ctx.message.author.id }, { x509 });
this.success(ctx.message.channel, 'x509 certificate successfully uploaded to your account.');
}
}