push changes
parent
72da156f27
commit
90fd5394da
|
@ -1,2 +0,0 @@
|
||||||
yarnPath: ".yarn/releases/yarn-berry.cjs"
|
|
||||||
nodeLinker: node-modules
|
|
|
@ -1,193 +1,207 @@
|
||||||
import Stripe from 'stripe';
|
import Stripe from 'stripe';
|
||||||
import eris from 'eris';
|
import eris from 'eris';
|
||||||
import pluris from 'pluris';
|
import pluris from 'pluris';
|
||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import Redis from 'ioredis';
|
import { promises as fs } from 'fs';
|
||||||
import { promises as fs } from 'fs';
|
import { Collection, Command, InteractionCommand, LocalStorage, Queue, Util, ServerManagement, Event } from '.';
|
||||||
import { Collection, Command, LocalStorage, Queue, Util, ServerManagement, Event } from '.';
|
import {
|
||||||
import {
|
Customer, CustomerInterface,
|
||||||
Customer, CustomerInterface,
|
CustomerPortal, CustomerPortalInterface,
|
||||||
CustomerPortal, CustomerPortalInterface,
|
ExecutiveOrder, ExecutiveOrderInterface,
|
||||||
ExecutiveOrder, ExecutiveOrderInterface,
|
File, FileInterface,
|
||||||
File, FileInterface,
|
Inquiry, InquiryInterface,
|
||||||
Inquiry, InquiryInterface,
|
Judgement, JudgementInterface,
|
||||||
Judgement, JudgementInterface,
|
Member, MemberInterface,
|
||||||
Member, MemberInterface,
|
Merchant, MerchantInterface,
|
||||||
Merchant, MerchantInterface,
|
Moderation, ModerationInterface,
|
||||||
Moderation, ModerationInterface,
|
Motion, MotionInterface,
|
||||||
Motion, MotionInterface,
|
Note, NoteInterface,
|
||||||
Note, NoteInterface,
|
PagerNumber, PagerNumberInterface,
|
||||||
PagerNumber, PagerNumberInterface,
|
Proclamation, ProclamationInterface,
|
||||||
Proclamation, ProclamationInterface,
|
Promo, PromoInterface,
|
||||||
Promo, PromoInterface,
|
Rank, RankInterface,
|
||||||
Rank, RankInterface,
|
Redirect, RedirectInterface,
|
||||||
Redirect, RedirectInterface,
|
Resolution, ResolutionInterface,
|
||||||
Resolution, ResolutionInterface,
|
SAA, SAAInterface,
|
||||||
SAA, SAAInterface,
|
Score, ScoreInterface,
|
||||||
Score, ScoreInterface,
|
ScoreHistorical, ScoreHistoricalInterface,
|
||||||
ScoreHistorical, ScoreHistoricalInterface,
|
Staff, StaffInterface,
|
||||||
Staff, StaffInterface,
|
Stat, StatInterface,
|
||||||
Stat, StatInterface,
|
} from '../models';
|
||||||
} from '../models';
|
import { Config } from '../../types'; // eslint-disable-line
|
||||||
import { Config } from '../../types'; // eslint-disable-line
|
|
||||||
|
pluris(eris, { endpoints: false });
|
||||||
pluris(eris);
|
|
||||||
|
export default class Client extends eris.Client {
|
||||||
export default class Client extends eris.Client {
|
public config: Config;
|
||||||
public config: Config;
|
|
||||||
|
public commands: Collection<Command>;
|
||||||
public commands: Collection<Command>;
|
|
||||||
|
public interactions: Collection<InteractionCommand>;
|
||||||
public events: Collection<Event>;
|
|
||||||
|
public events: Collection<Event>;
|
||||||
public intervals: Collection<NodeJS.Timeout>;
|
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
public util: Util;
|
public intervals: Collection<NodeJS.Timeout>;
|
||||||
|
|
||||||
public serverManagement: ServerManagement;
|
public util: Util;
|
||||||
|
|
||||||
public queue: Queue;
|
public serverManagement: ServerManagement;
|
||||||
|
|
||||||
public stripe: Stripe;
|
public queue: Queue;
|
||||||
|
|
||||||
|
public stripe: Stripe;
|
||||||
|
|
||||||
public db: {
|
|
||||||
Customer: mongoose.Model<CustomerInterface>,
|
|
||||||
CustomerPortal: mongoose.Model<CustomerPortalInterface>,
|
public db: {
|
||||||
ExecutiveOrder: mongoose.Model<ExecutiveOrderInterface>,
|
Customer: mongoose.Model<CustomerInterface>,
|
||||||
File: mongoose.Model<FileInterface>,
|
CustomerPortal: mongoose.Model<CustomerPortalInterface>,
|
||||||
Inquiry: mongoose.Model<InquiryInterface>,
|
ExecutiveOrder: mongoose.Model<ExecutiveOrderInterface>,
|
||||||
Judgement: mongoose.Model<JudgementInterface>,
|
File: mongoose.Model<FileInterface>,
|
||||||
Member: mongoose.Model<MemberInterface>,
|
Inquiry: mongoose.Model<InquiryInterface>,
|
||||||
Merchant: mongoose.Model<MerchantInterface>,
|
Judgement: mongoose.Model<JudgementInterface>,
|
||||||
Moderation: mongoose.Model<ModerationInterface>,
|
Member: mongoose.Model<MemberInterface>,
|
||||||
Motion: mongoose.Model<MotionInterface>,
|
Merchant: mongoose.Model<MerchantInterface>,
|
||||||
Note: mongoose.Model<NoteInterface>,
|
Moderation: mongoose.Model<ModerationInterface>,
|
||||||
PagerNumber: mongoose.Model<PagerNumberInterface>,
|
Motion: mongoose.Model<MotionInterface>,
|
||||||
Proclamation: mongoose.Model<ProclamationInterface>,
|
Note: mongoose.Model<NoteInterface>,
|
||||||
Promo: mongoose.Model<PromoInterface>,
|
PagerNumber: mongoose.Model<PagerNumberInterface>,
|
||||||
Rank: mongoose.Model<RankInterface>,
|
Proclamation: mongoose.Model<ProclamationInterface>,
|
||||||
Redirect: mongoose.Model<RedirectInterface>,
|
Promo: mongoose.Model<PromoInterface>,
|
||||||
Resolution: mongoose.Model<ResolutionInterface>,
|
Rank: mongoose.Model<RankInterface>,
|
||||||
SAA: mongoose.Model<SAAInterface>,
|
Redirect: mongoose.Model<RedirectInterface>,
|
||||||
Score: mongoose.Model<ScoreInterface>,
|
Resolution: mongoose.Model<ResolutionInterface>,
|
||||||
ScoreHistorical: mongoose.Model<ScoreHistoricalInterface>,
|
SAA: mongoose.Model<SAAInterface>,
|
||||||
Staff: mongoose.Model<StaffInterface>,
|
Score: mongoose.Model<ScoreInterface>,
|
||||||
Stat: mongoose.Model<StatInterface>,
|
ScoreHistorical: mongoose.Model<ScoreHistoricalInterface>,
|
||||||
local: { muted: LocalStorage }
|
Staff: mongoose.Model<StaffInterface>,
|
||||||
};
|
Stat: mongoose.Model<StatInterface>,
|
||||||
|
local: { muted: LocalStorage }
|
||||||
constructor(token: string, options?: eris.ClientOptions) {
|
};
|
||||||
super(token, options);
|
|
||||||
this.commands = new Collection<Command>();
|
constructor(token: string, options?: eris.ClientOptions) {
|
||||||
this.events = new Collection<Event>();
|
super(token, options);
|
||||||
this.intervals = new Collection<NodeJS.Timeout>();
|
this.commands = new Collection<Command>();
|
||||||
this.queue = new Queue(this);
|
this.interactions = new Collection<InteractionCommand>();
|
||||||
this.db = {
|
this.events = new Collection<Event>();
|
||||||
Customer,
|
// eslint-disable-next-line no-undef
|
||||||
CustomerPortal,
|
this.intervals = new Collection<NodeJS.Timeout>();
|
||||||
ExecutiveOrder,
|
this.queue = new Queue(this);
|
||||||
File,
|
this.db = {
|
||||||
Inquiry,
|
Customer,
|
||||||
Judgement,
|
CustomerPortal,
|
||||||
Member,
|
ExecutiveOrder,
|
||||||
Merchant,
|
File,
|
||||||
Moderation,
|
Inquiry,
|
||||||
Motion,
|
Judgement,
|
||||||
Note,
|
Member,
|
||||||
PagerNumber,
|
Merchant,
|
||||||
Promo,
|
Moderation,
|
||||||
Proclamation,
|
Motion,
|
||||||
Rank,
|
Note,
|
||||||
Redirect,
|
PagerNumber,
|
||||||
Resolution,
|
Promo,
|
||||||
SAA,
|
Proclamation,
|
||||||
Score,
|
Rank,
|
||||||
ScoreHistorical,
|
Redirect,
|
||||||
Staff,
|
Resolution,
|
||||||
Stat,
|
SAA,
|
||||||
local: { muted: new LocalStorage('muted') },
|
Score,
|
||||||
};
|
ScoreHistorical,
|
||||||
}
|
Staff,
|
||||||
|
Stat,
|
||||||
get report() {
|
local: { muted: new LocalStorage('muted') },
|
||||||
return this.util.report;
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
get pbx() {
|
get report() {
|
||||||
return this.util.pbx;
|
return this.util.report;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get pbx() {
|
||||||
public async loadDatabase() {
|
return this.util.pbx;
|
||||||
await mongoose.connect(this.config.mongoDB, {
|
}
|
||||||
useNewUrlParser: true,
|
|
||||||
useUnifiedTopology: true,
|
|
||||||
poolSize: 50,
|
public async loadDatabase() {
|
||||||
});
|
mongoose.connect(this.config.mongoDB, {
|
||||||
|
minPoolSize: 50,
|
||||||
const statMessages = await this.db.Stat.findOne({ name: 'messages' });
|
});
|
||||||
const statCommands = await this.db.Stat.findOne({ name: 'commands' });
|
|
||||||
const statPages = await this.db.Stat.findOne({ name: 'pages' });
|
const statMessages = await this.db.Stat.findOne({ name: 'messages' });
|
||||||
const statRequests = await this.db.Stat.findOne({ name: 'requests' });
|
const statCommands = await this.db.Stat.findOne({ name: 'commands' });
|
||||||
|
const statPages = await this.db.Stat.findOne({ name: 'pages' });
|
||||||
if (!statMessages) {
|
const statRequests = await this.db.Stat.findOne({ name: 'requests' });
|
||||||
await (new this.db.Stat({ name: 'messages', value: 0 }).save());
|
|
||||||
}
|
if (!statMessages) {
|
||||||
if (!statCommands) {
|
await (new this.db.Stat({ name: 'messages', value: 0 }).save());
|
||||||
await (new this.db.Stat({ name: 'commands', value: 0 }).save());
|
}
|
||||||
}
|
if (!statCommands) {
|
||||||
if (!statPages) {
|
await (new this.db.Stat({ name: 'commands', value: 0 }).save());
|
||||||
await (new this.db.Stat({ name: 'pages', value: 0 }).save());
|
}
|
||||||
}
|
if (!statPages) {
|
||||||
if (!statRequests) {
|
await (new this.db.Stat({ name: 'pages', value: 0 }).save());
|
||||||
await (new this.db.Stat({ name: 'requests', value: 0 }).save());
|
}
|
||||||
}
|
if (!statRequests) {
|
||||||
}
|
await (new this.db.Stat({ name: 'requests', value: 0 }).save());
|
||||||
|
}
|
||||||
public loadPlugins() {
|
}
|
||||||
this.util = new Util(this);
|
|
||||||
this.serverManagement = new ServerManagement(this);
|
public loadPlugins() {
|
||||||
this.stripe = new Stripe(this.config.stripeKey, { apiVersion: null, typescript: true });
|
this.util = new Util(this);
|
||||||
}
|
this.serverManagement = new ServerManagement(this);
|
||||||
|
this.stripe = new Stripe(this.config.stripeKey, { apiVersion: null, typescript: true });
|
||||||
public async loadIntervals() {
|
}
|
||||||
const intervalFiles = await fs.readdir(`${__dirname}/../intervals`);
|
|
||||||
intervalFiles.forEach((file) => {
|
public async loadIntervals() {
|
||||||
const intervalName = file.split('.')[0];
|
const intervalFiles = await fs.readdir(`${__dirname}/../intervals`);
|
||||||
if (file === 'index.js') return;
|
intervalFiles.forEach((file) => {
|
||||||
const interval: NodeJS.Timeout = (require(`${__dirname}/../intervals/${file}`).default)(this);
|
const intervalName = file.split('.')[0];
|
||||||
this.intervals.add(intervalName, interval);
|
if (file === 'index.js') return;
|
||||||
this.util.signale.success(`Successfully loaded interval: ${intervalName}`);
|
// eslint-disable-next-line no-undef
|
||||||
});
|
const interval: NodeJS.Timeout = (require(`${__dirname}/../intervals/${file}`).default)(this);
|
||||||
}
|
this.intervals.add(intervalName, interval);
|
||||||
|
this.util.signale.success(`Successfully loaded interval: ${intervalName}`);
|
||||||
public async loadEvents(eventFiles: { [s: string]: typeof Event; } | ArrayLike<typeof Event>) {
|
});
|
||||||
const evtFiles = Object.entries<typeof Event>(eventFiles);
|
}
|
||||||
for (const [name, Ev] of evtFiles) {
|
|
||||||
const event = new Ev(this);
|
public async loadEvents(eventFiles: { [s: string]: typeof Event; } | ArrayLike<typeof Event>) {
|
||||||
this.events.add(event.event, event);
|
const evtFiles = Object.entries<typeof Event>(eventFiles);
|
||||||
this.on(event.event, event.run);
|
for (const [name, Ev] of evtFiles) {
|
||||||
this.util.signale.success(`Successfully loaded event: ${name}`);
|
const event = new Ev(this);
|
||||||
delete require.cache[require.resolve(`${__dirname}/../events/${name}`)];
|
this.events.add(event.event, event);
|
||||||
}
|
this.on(event.event, event.run);
|
||||||
}
|
this.util.signale.success(`Successfully loaded event: ${name}`);
|
||||||
|
delete require.cache[require.resolve(`${__dirname}/../events/${name}`)];
|
||||||
public async loadCommands(commandFiles: { [s: string]: typeof Command; } | ArrayLike<typeof Command>) {
|
}
|
||||||
const cmdFiles = Object.values<typeof Command>(commandFiles);
|
}
|
||||||
for (const Cmd of cmdFiles) {
|
|
||||||
const command = new Cmd(this);
|
public async loadCommands(commandFiles: { [s: string]: typeof Command; } | ArrayLike<typeof Command>) {
|
||||||
if (command.subcmds.length) {
|
const cmdFiles = Object.values<typeof Command>(commandFiles);
|
||||||
command.subcmds.forEach((C) => {
|
for (const Cmd of cmdFiles) {
|
||||||
const cmd: Command = new C(this);
|
const command = new Cmd(this);
|
||||||
command.subcommands.add(cmd.name, cmd);
|
if (command.subcmds.length) {
|
||||||
this.util.signale.success(`Successfully loaded subcommand ${cmd.name} under ${command.name}`);
|
command.subcmds.forEach((C) => {
|
||||||
});
|
const cmd: Command = new C(this);
|
||||||
}
|
command.subcommands.add(cmd.name, cmd);
|
||||||
delete command.subcmds;
|
this.util.signale.success(`Successfully loaded subcommand ${cmd.name} under ${command.name}`);
|
||||||
this.commands.add(command.name, command);
|
});
|
||||||
this.util.signale.success(`Successfully loaded command: ${command.name}`);
|
}
|
||||||
}
|
delete command.subcmds;
|
||||||
}
|
this.commands.add(command.name, command);
|
||||||
}
|
this.util.signale.success(`Successfully loaded command: ${command.name}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async loadInteractions(interactionFiles: { [s: string]: typeof InteractionCommand; } | ArrayLike<typeof InteractionCommand>) {
|
||||||
|
const intFiles = Object.values<typeof InteractionCommand>(interactionFiles);
|
||||||
|
for (const Int of intFiles) {
|
||||||
|
const interaction = new Int(this);
|
||||||
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
const c = await this.createGuildCommand(this.config.guildID, interaction.serializeData());
|
||||||
|
this.interactions.add(c.application_id, interaction);
|
||||||
|
this.util.signale.success(`Successfully loaded interaction: ${interaction.name}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue