diff --git a/src/Client.ts b/src/Client.ts deleted file mode 100644 index e8638a4..0000000 --- a/src/Client.ts +++ /dev/null @@ -1,138 +0,0 @@ -import Eris from 'eris'; -import Redis from 'ioredis'; -import mongoose from 'mongoose'; -import signale from 'signale'; -import fs from 'fs-extra'; -import config from './config.json'; -import CSCLI from './cscli/main'; -import { Server } from './api'; -import { Account, AccountInterface, Moderation, ModerationInterface, Domain, DomainInterface, Tier, TierInterface } from './models'; -import { emojis } from './stores'; -import { Command, Util, Collection } from './class'; -import * as commands from './commands'; - - -export default class Client extends Eris.Client { - public config: { 'token': string; 'cloudflare': string; 'prefix': string; 'emailPass': string; 'mongoURL': string; 'port': number; 'keyPair': { 'publicKey': string; 'privateKey': string; }; }; - - public util: Util; - - public commands: Collection; - - public db: { Account: mongoose.Model; Domain: mongoose.Model; Moderation: mongoose.Model; Tier: mongoose.Model; }; - - public redis: Redis.Redis; - - public stores: { emojis: { success: string, loading: string, error: string }; }; - - public functions: Collection; - - public signale: signale.Signale; - - public server: Server; - - public updating: boolean; - - public buildError: boolean - - constructor() { - super(config.token, { getAllUsers: true, restMode: true, defaultImageFormat: 'png' }); - - process.title = 'cloudservices'; - this.config = config; - this.util = new Util(this); - this.commands = new Collection(); - this.functions = new Collection(); - this.db = { Account, Domain, Moderation, Tier }; - this.redis = new Redis(); - this.stores = { emojis }; - this.signale = signale; - this.signale.config({ - displayDate: true, - displayTimestamp: true, - displayFilename: true, - }); - this.updating = false; - this.buildError = false; - this.events(); - this.loadFunctions(); - this.init(); - } - - private async events() { - process.on('unhandledRejection', (error) => { - this.signale.error(error); - }); - } - - private async loadFunctions() { - const functions = await fs.readdir('./functions'); - functions.forEach(async (func) => { - if (func === 'index.ts' || func === 'index.js') return; - try { - const funcRequire: Function = require(`./functions/${func}`).default; - this.functions.set(func.split('.')[0], funcRequire); - } catch (error) { - this.signale.error(`Error occured loading ${func}`); - await this.util.handleError(error); - } - }); - } - - public loadCommand(CommandFile: any) { - // eslint-disable-next-line no-useless-catch - try { - // eslint-disable-next-line - const command: Command = new CommandFile(this); - if (command.subcmds.length) { - command.subcmds.forEach((C) => { - const cmd: Command = new C(this); - command.subcommands.add(cmd.name, cmd); - }); - } - delete command.subcmds; - this.commands.add(command.name, command); - this.signale.complete(`Loaded command ${command.name}`); - } catch (err) { throw err; } - } - - public async init() { - const evtFiles = await fs.readdir('./events/'); - Object.values(commands).forEach((c: Function) => this.loadCommand(c)); - - evtFiles.forEach((file) => { - const eventName = file.split('.')[0]; - if (file === 'index.js') return; - // eslint-disable-next-line - const event = new (require(`./events/${file}`).default)(this); - this.signale.complete(`Loaded event ${eventName}`); - this.on(eventName, (...args) => event.run(...args)); - delete require.cache[require.resolve(`./events/${file}`)]; - }); - - await mongoose.connect(config.mongoURL, { useNewUrlParser: true, useUnifiedTopology: true }); - await this.connect(); - this.on('ready', () => { - this.signale.info(`Connected to Discord as ${this.user.username}#${this.user.discriminator}`); - }); - const intervals = await fs.readdir('./intervals'); - intervals.forEach((interval) => { - // eslint-disable-next-line - if (interval === 'index.js') return; - require(`./intervals/${interval}`).default(this); - this.signale.complete(`Loaded interval ${interval.split('.')[0]}`); - }); - this.server = new Server(this, { port: this.config.port }); - // eslint-disable-next-line no-new - new CSCLI(this); - - const corepath = '/opt/CloudServices/dist'; - const cmdFiles = await fs.readdir('/opt/CloudServices/dist/commands'); - cmdFiles.forEach((f) => delete require.cache[`${corepath}/${f}`]); - delete require.cache[`${corepath}/config.json`]; - delete require.cache[`${corepath}/class/Util`]; - } -} - -// eslint-disable-next-line -new Client(); diff --git a/src/api/Security.ts b/src/api/Security.ts deleted file mode 100644 index 5488662..0000000 --- a/src/api/Security.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* eslint-disable no-underscore-dangle */ -import crypto from 'crypto'; -import { Request } from 'express'; -import { Client } from '..'; -import { AccountInterface } from '../models'; - -export default class Security { - public client: Client; - - protected readonly keyBase: { key: string, iv: string }; - - constructor(client: Client) { - this.client = client; - this.keyBase = require(`${process.cwd()}/keys.json`); - } - - get keys() { - return { - key: Buffer.from(this.keyBase.key, 'base64'), - iv: Buffer.from(this.keyBase.iv, 'base64'), - }; - } - - /** - * Creates a new Bearer token. - * @param _id The Mongoose Document property labeled ._id - */ - public async createBearer(_id: string): Promise { - let account = await this.client.db.Account.findOne({ _id }); - if (!account) throw new Error(`Account [${_id}] cannot be found.`); - const salt = crypto.randomBytes(50).toString('base64'); - const cipher = crypto.createCipheriv('aes-256-gcm', this.keys.key, this.keys.iv); - await account.updateOne({ salt }); - account = await this.client.db.Account.findOne({ _id }); - let encrypted = cipher.update(JSON.stringify(account), 'utf8', 'base64'); - encrypted += cipher.final('base64'); - await account.updateOne({ authTag: cipher.getAuthTag() }); - return `${salt}:${encrypted}`; - } - - /** - * If the bearer token is valid, will return the Account, else will return null. - * @param bearer The bearer token provided. - */ - public async checkBearer(bearer: string): Promise { - const decipher = crypto.createDecipheriv('aes-256-gcm', this.keys.key, this.keys.iv); - try { - const salt = bearer.split(':')[0]; - const saltCheck = await this.client.db.Account.findOne({ salt }); - const encrypted = bearer.split(':')[1]; - let decrypted = decipher.update(encrypted, 'base64', 'utf8'); - decipher.setAuthTag(saltCheck.authTag); - decrypted += decipher.final('utf8'); - const json = JSON.parse(decrypted); - const account = await this.client.db.Account.findOne({ username: json.username }); - if (saltCheck.salt !== account.salt) return null; - return account; - } catch (error) { - this.client.util.handleError(error); - return null; - } - } - - /** - * Returns the Bearer token, searches in headers and query. - * @param req The Request object from Express. - */ - public extractBearer(req: Request): string { - if (req.headers.authorization && req.headers.authorization.split(' ')[0] === 'Bearer') { - return req.headers.authorization.split(' ')[1]; - } - if (req.query && req.query.token) { - return req.query.token as string; - } - return '0000000000'; - } -} diff --git a/src/api/Server.ts b/src/api/Server.ts deleted file mode 100644 index db55dcf..0000000 --- a/src/api/Server.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* eslint-disable no-useless-return */ -import express from 'express'; -import bodyParser from 'body-parser'; -import helmet from 'helmet'; -import fs from 'fs-extra'; -import { Client } from '..'; -import { Security } from '.'; -import { Collection, Route } from '../class'; - -export default class Server { - public routes: Collection - - public client: Client; - - public security: Security; - - public app: express.Express; - - public options: { port: number } - - constructor(client: Client, options?: { port: number }) { - this.options = options; - this.routes = new Collection(); - this.client = client; - this.security = new Security(this.client); - this.app = express(); - this.connect(); - this.loadRoutes(); - } - - private async loadRoutes(): Promise { - const routes = await fs.readdir(`${__dirname}/routes`); - routes.forEach(async (routeFile) => { - if (routeFile === 'index.js') return; - try { - // eslint-disable-next-line new-cap - const route: Route = new (require(`${__dirname}/routes/${routeFile}`).default)(this); - if (route.conf.deprecated === true) { - route.deprecated(); - } else if (route.conf.maintenance === true) { - route.maintenance(); - } else { - route.bind(); - } - this.routes.set(route.conf.path, route); - this.app.use(route.conf.path, route.router); - this.client.signale.success(`Successfully loaded route ${route.conf.path}`); - } catch (error) { - this.client.util.handleError(error); - } - }); - } - - private connect(): void { - this.app.set('trust proxy', 'loopback'); - this.app.use(helmet({ - hsts: false, - hidePoweredBy: false, - contentSecurityPolicy: { - directives: { - defaultSrc: ["'self'"], - }, - }, - })); - this.app.use(bodyParser.json()); - this.app.listen(this.options.port, () => { - this.client.signale.success(`API Server listening on port ${this.options.port}`); - }); - } -} diff --git a/src/class/Client.ts b/src/class/Client.ts index 5ca7265..74dfe45 100644 --- a/src/class/Client.ts +++ b/src/class/Client.ts @@ -66,11 +66,11 @@ export default class Client extends Eris.Client { } private async loadFunctions() { - const functions = await fs.readdir('./functions'); + const functions = await fs.readdir('../functions'); functions.forEach(async (func) => { if (func === 'index.ts' || func === 'index.js') return; try { - const funcRequire: Function = require(`./functions/${func}`).default; + const funcRequire: Function = require(`../functions/${func}`).default; this.functions.set(func.split('.')[0], funcRequire); } catch (error) { this.signale.error(`Error occured loading ${func}`); @@ -97,17 +97,17 @@ export default class Client extends Eris.Client { } public async init() { - const evtFiles = await fs.readdir('./events/'); + const evtFiles = await fs.readdir('../events/'); Object.values(commands).forEach((c: Function) => this.loadCommand(c)); evtFiles.forEach((file) => { const eventName = file.split('.')[0]; if (file === 'index.js') return; // eslint-disable-next-line - const event = new (require(`./events/${file}`).default)(this); + const event = new (require(`../events/${file}`).default)(this); this.signale.complete(`Loaded event ${eventName}`); this.on(eventName, (...args) => event.run(...args)); - delete require.cache[require.resolve(`./events/${file}`)]; + delete require.cache[require.resolve(`../events/${file}`)]; }); await mongoose.connect(config.mongoURL, { useNewUrlParser: true, useUnifiedTopology: true }); @@ -115,11 +115,11 @@ export default class Client extends Eris.Client { this.on('ready', () => { this.signale.info(`Connected to Discord as ${this.user.username}#${this.user.discriminator}`); }); - const intervals = await fs.readdir('./intervals'); + const intervals = await fs.readdir('../intervals'); intervals.forEach((interval) => { // eslint-disable-next-line if (interval === 'index.js') return; - require(`./intervals/${interval}`).default(this); + require(`../intervals/${interval}`).default(this); this.signale.complete(`Loaded interval ${interval.split('.')[0]}`); }); this.server = new Server(this, { port: this.config.port }); diff --git a/src/class/Command.ts b/src/class/Command.ts index 3c987de..bbf3ecf 100644 --- a/src/class/Command.ts +++ b/src/class/Command.ts @@ -1,6 +1,5 @@ -import { Message, TextableChannel, Textable } from 'eris'; -import { Client } from '..'; -import { Collection } from '.'; +import { Message, TextableChannel } from 'eris'; +import { Client, Collection } from '.'; export default class Command { name: string diff --git a/src/class/Route.ts b/src/class/Route.ts index d96e24b..1374644 100644 --- a/src/class/Route.ts +++ b/src/class/Route.ts @@ -1,6 +1,6 @@ /* eslint-disable consistent-return */ import { Request, Response, NextFunction, Router as router } from 'express'; -import { Server } from '../api'; +import { Server } from '.'; export default class Route { public server: Server; diff --git a/src/class/Security.ts b/src/class/Security.ts index 5488662..7dee703 100644 --- a/src/class/Security.ts +++ b/src/class/Security.ts @@ -1,7 +1,7 @@ /* eslint-disable no-underscore-dangle */ import crypto from 'crypto'; import { Request } from 'express'; -import { Client } from '..'; +import { Client } from '.'; import { AccountInterface } from '../models'; export default class Security { diff --git a/src/class/Server.ts b/src/class/Server.ts index ded4c5f..ce4c056 100644 --- a/src/class/Server.ts +++ b/src/class/Server.ts @@ -3,9 +3,9 @@ import express from 'express'; import bodyParser from 'body-parser'; import helmet from 'helmet'; import fs from 'fs-extra'; -import { Client } from '..'; +import { Client, Collection, Route } from '.'; import { Security } from '../api'; -import { Collection, Route } from '.'; + export default class Server { public routes: Collection diff --git a/src/class/Util.ts b/src/class/Util.ts index db66f7d..afa999c 100644 --- a/src/class/Util.ts +++ b/src/class/Util.ts @@ -7,9 +7,8 @@ import { Message, PrivateChannel, GroupChannel, Member, User } from 'eris'; import uuid from 'uuid/v4'; import moment from 'moment'; import fs from 'fs'; -import { Client } from '..'; import { getUserByUid } from '../functions'; -import { AccountUtil, Command, RichEmbed } from '.'; +import { AccountUtil, Client, Command, RichEmbed } from '.'; import { ModerationInterface, AccountInterface, Account } from '../models'; export default class Util { diff --git a/src/class/index.ts b/src/class/index.ts index c40f8ca..4e0bb2e 100644 --- a/src/class/index.ts +++ b/src/class/index.ts @@ -4,4 +4,6 @@ export { default as Collection } from './Collection'; export { default as Command } from './Command'; export { default as RichEmbed } from './RichEmbed'; export { default as Route } from './Route'; +export { default as Security } from './Security'; +export { default as Server } from './Server'; export { default as Util } from './Util'; diff --git a/src/commands/announce.ts b/src/commands/announce.ts index 47bc21f..5ee1d2c 100644 --- a/src/commands/announce.ts +++ b/src/commands/announce.ts @@ -1,6 +1,5 @@ import { Message } from 'eris'; -import { Client } from '..'; -import { Command } from '../class'; +import { Client, Command } from '../class'; export default class Announce extends Command { constructor(client: Client) { diff --git a/src/commands/bearer.ts b/src/commands/bearer.ts index 19751c9..4cd92d0 100644 --- a/src/commands/bearer.ts +++ b/src/commands/bearer.ts @@ -1,6 +1,5 @@ import { Message } from 'eris'; -import { Command } from '../class'; -import { Client } from '..'; +import { Client, Command } from '../class'; export default class Bearer extends Command { constructor(client: Client) { diff --git a/src/commands/cloudflare.ts b/src/commands/cloudflare.ts index f912733..6415dda 100644 --- a/src/commands/cloudflare.ts +++ b/src/commands/cloudflare.ts @@ -1,7 +1,6 @@ import axios from 'axios'; import { Message } from 'eris'; -import { Client } from '..'; -import { Command } from '../class'; +import { Client, Command } from '../class'; export default class Cloudflare extends Command { constructor(client: Client) { diff --git a/src/commands/createaccount.ts b/src/commands/createaccount.ts index d3bba47..1ca5b34 100644 --- a/src/commands/createaccount.ts +++ b/src/commands/createaccount.ts @@ -1,6 +1,5 @@ import { Message, PrivateChannel, GroupChannel } from 'eris'; -import { Client } from '..'; -import { Command, RichEmbed } from '../class'; +import { Client, Command } from '../class'; export default class CreateAccount extends Command { constructor(client: Client) { diff --git a/src/commands/cwg.ts b/src/commands/cwg.ts index b7a4ade..662e77d 100644 --- a/src/commands/cwg.ts +++ b/src/commands/cwg.ts @@ -1,6 +1,5 @@ import { Message } from 'eris'; -import { Command } from '../class'; -import { Client } from '..'; +import { Client, Command } from '../class'; import Create from './cwg_create'; import Data from './cwg_data'; import Delete from './cwg_delete'; diff --git a/src/commands/cwg_create.ts b/src/commands/cwg_create.ts index ffaa006..2ace78e 100644 --- a/src/commands/cwg_create.ts +++ b/src/commands/cwg_create.ts @@ -3,8 +3,7 @@ import axios from 'axios'; import { randomBytes } from 'crypto'; import { Message } from 'eris'; import { AccountInterface } from '../models'; -import { Command, RichEmbed } from '../class'; -import { Client } from '..'; +import { Client, Command, RichEmbed } from '../class'; import { parseCertificate } from '../functions'; export default class CWG_Create extends Command { diff --git a/src/commands/cwg_data.ts b/src/commands/cwg_data.ts index cfae12c..d3f8a8a 100644 --- a/src/commands/cwg_data.ts +++ b/src/commands/cwg_data.ts @@ -3,8 +3,7 @@ import moment from 'moment'; import x509 from '@ghaiklor/x509'; import { createPaginationEmbed } from 'eris-pagination'; import { Message } from 'eris'; -import { Command, RichEmbed } from '../class'; -import { Client } from '..'; +import { Client, Command, RichEmbed } from '../class'; export default class CWG_Data extends Command { constructor(client: Client) { diff --git a/src/commands/cwg_delete.ts b/src/commands/cwg_delete.ts index ab6af76..a1c50f1 100644 --- a/src/commands/cwg_delete.ts +++ b/src/commands/cwg_delete.ts @@ -1,8 +1,7 @@ import fs from 'fs-extra'; import axios from 'axios'; import { Message } from 'eris'; -import { Command, RichEmbed } from '../class'; -import { Client } from '..'; +import { Client, Command, RichEmbed } from '../class'; export default class CWG_Delete extends Command { constructor(client: Client) { diff --git a/src/commands/cwg_updatecert.ts b/src/commands/cwg_updatecert.ts index 2fbc230..9e3bd7d 100644 --- a/src/commands/cwg_updatecert.ts +++ b/src/commands/cwg_updatecert.ts @@ -1,8 +1,7 @@ import { writeFile, unlink } from 'fs-extra'; import axios from 'axios'; import { Message } from 'eris'; -import { Command } from '../class'; -import { Client } from '..'; +import { Client, Command } from '../class'; export default class CWG_UpdateCert extends Command { constructor(client: Client) { diff --git a/src/commands/deleteaccount.ts b/src/commands/deleteaccount.ts index 28a4431..b3818ca 100644 --- a/src/commands/deleteaccount.ts +++ b/src/commands/deleteaccount.ts @@ -1,7 +1,6 @@ import { Message, PrivateChannel } from 'eris'; import uuid from 'uuid/v4'; -import { Command } from '../class'; -import { Client } from '..'; +import { Client, Command } from '../class'; export default class DeleteAccount extends Command { constructor(client: Client) { diff --git a/src/commands/emailcode.ts b/src/commands/emailcode.ts index 6ba4475..6e3901e 100644 --- a/src/commands/emailcode.ts +++ b/src/commands/emailcode.ts @@ -1,7 +1,6 @@ import { randomBytes } from 'crypto'; import { Message } from 'eris'; -import { Client } from '..'; -import { Command, RichEmbed } from '../class'; +import { Client, Command } from '../class'; export default class EmailCode extends Command { constructor(client: Client) { diff --git a/src/commands/eval.ts b/src/commands/eval.ts index 495b141..7ed5f07 100644 --- a/src/commands/eval.ts +++ b/src/commands/eval.ts @@ -2,8 +2,7 @@ import axios from 'axios'; import { Message } from 'eris'; import { inspect } from 'util'; -import { Client } from '..'; -import { Command } from '../class'; +import { Client, Command } from '../class'; export default class Eval extends Command { constructor(client: Client) { diff --git a/src/commands/exec.ts b/src/commands/exec.ts index 2dc185a..40bc6d1 100644 --- a/src/commands/exec.ts +++ b/src/commands/exec.ts @@ -1,7 +1,6 @@ import { Message } from 'eris'; import axios from 'axios'; -import { Client } from '..'; -import { Command } from '../class'; +import { Client, Command } from '../class'; export default class Exec extends Command { constructor(client: Client) { diff --git a/src/commands/help.ts b/src/commands/help.ts index e28b118..e450d2b 100644 --- a/src/commands/help.ts +++ b/src/commands/help.ts @@ -1,7 +1,6 @@ import { Message } from 'eris'; import { createPaginationEmbed } from 'eris-pagination'; -import { Client } from '..'; -import { Command, RichEmbed } from '../class'; +import { Client, Command, RichEmbed } from '../class'; export default class Help extends Command { constructor(client: Client) { diff --git a/src/commands/index.ts b/src/commands/index.ts index 36aa044..029babf 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -4,7 +4,6 @@ export { default as cloudflare } from './cloudflare'; export { default as createaccount } from './createaccount'; export { default as cwg } from './cwg'; export { default as deleteaccount } from './deleteaccount'; -export { default as disk } from './disk'; export { default as emailcode } from './emailcode'; export { default as eval } from './eval'; export { default as exec } from './exec'; @@ -14,13 +13,10 @@ export { default as load } from './load'; export { default as lock } from './lock'; export { default as modlogs } from './modlogs'; export { default as notify } from './notify'; -export { default as parse } from './parse'; -export { default as parseall } from './parseall'; export { default as ping } from './ping'; export { default as pull } from './pull'; export { default as resetpassword } from './resetpassword'; export { default as restart } from './restart'; -export { default as securesign } from './securesign'; export { default as setlimit } from './setlimit'; export { default as sysinfo } from './sysinfo'; export { default as systemd } from './systemd'; @@ -29,4 +25,3 @@ export { default as unban } from './unban'; export { default as unlock } from './unlock'; export { default as warn } from './warn'; export { default as whois } from './whois'; -export { default as whoisold } from './whoisold'; diff --git a/src/commands/limits.ts b/src/commands/limits.ts index 1db6bf4..468b6de 100644 --- a/src/commands/limits.ts +++ b/src/commands/limits.ts @@ -1,8 +1,7 @@ import { Message } from 'eris'; -import { Command, RichEmbed } from '../class'; +import { Client, Command, RichEmbed } from '../class'; import { dataConversion } from '../functions'; import setRamNotification from './limits_setramnotification'; -import { Client } from '..'; export default class Limits extends Command { constructor(client: Client) { diff --git a/src/commands/limits_setramnotification.ts b/src/commands/limits_setramnotification.ts index bc8e18f..ae78ae6 100644 --- a/src/commands/limits_setramnotification.ts +++ b/src/commands/limits_setramnotification.ts @@ -1,6 +1,5 @@ import { Message } from 'eris'; -import { Command, RichEmbed } from '../class'; -import { Client } from '..'; +import { Client, Command } from '../class'; export default class Limits_SetRAMNotification extends Command { constructor(client: Client) { diff --git a/src/commands/load.ts b/src/commands/load.ts index 98d4d0f..915dc2c 100644 --- a/src/commands/load.ts +++ b/src/commands/load.ts @@ -1,6 +1,5 @@ import { Message } from 'eris'; -import { Client } from '..'; -import { Command } from '../class'; +import { Client, Command } from '../class'; export default class Load extends Command { constructor(client: Client) { diff --git a/src/commands/lock.ts b/src/commands/lock.ts index 10ccc77..831dbad 100644 --- a/src/commands/lock.ts +++ b/src/commands/lock.ts @@ -1,7 +1,6 @@ import moment, { unitOfTime } from 'moment'; import { Message } from 'eris'; -import { Client } from '..'; -import { Command } from '../class'; +import { Client, Command } from '../class'; export default class Lock extends Command { constructor(client: Client) { diff --git a/src/commands/modlogs.ts b/src/commands/modlogs.ts index bc13075..10d552f 100644 --- a/src/commands/modlogs.ts +++ b/src/commands/modlogs.ts @@ -1,7 +1,6 @@ import { Message } from 'eris'; import { createPaginationEmbed } from 'eris-pagination'; -import { Client } from '..'; -import { Command, RichEmbed } from '../class'; +import { Client, Command, RichEmbed } from '../class'; export default class Modlogs extends Command { constructor(client: Client) { diff --git a/src/commands/notify.ts b/src/commands/notify.ts index 002c86b..df7d76b 100644 --- a/src/commands/notify.ts +++ b/src/commands/notify.ts @@ -1,6 +1,5 @@ import { Message } from 'eris'; -import { Client } from '..'; -import { Command, RichEmbed } from '../class'; +import { Client, Command, RichEmbed } from '../class'; export default class Notify extends Command { constructor(client: Client) { diff --git a/src/commands/ping.ts b/src/commands/ping.ts index a7c956d..76e3403 100644 --- a/src/commands/ping.ts +++ b/src/commands/ping.ts @@ -1,6 +1,5 @@ import { Message } from 'eris'; -import { Client } from '..'; -import { Command } from '../class'; +import { Client, Command } from '../class'; export default class Ping extends Command { constructor(client: Client) { diff --git a/src/commands/pull.ts b/src/commands/pull.ts index 557b54f..9c9ec1c 100644 --- a/src/commands/pull.ts +++ b/src/commands/pull.ts @@ -1,7 +1,6 @@ import { Message } from 'eris'; import axios from 'axios'; -import { Client } from '..'; -import { Command } from '../class'; +import { Client, Command } from '../class'; export default class Pull extends Command { constructor(client: Client) { diff --git a/src/commands/resetpassword.ts b/src/commands/resetpassword.ts index ea48bfc..eb9b8fd 100644 --- a/src/commands/resetpassword.ts +++ b/src/commands/resetpassword.ts @@ -1,6 +1,5 @@ import { Message } from 'eris'; -import { Client } from '..'; -import { Command } from '../class'; +import { Client, Command } from '../class'; export default class ResetPassword extends Command { constructor(client: Client) { diff --git a/src/commands/restart.ts b/src/commands/restart.ts index 31847d1..38050a7 100644 --- a/src/commands/restart.ts +++ b/src/commands/restart.ts @@ -1,6 +1,5 @@ import { Message } from 'eris'; -import { Client } from '..'; -import { Command } from '../class'; +import { Client, Command } from '../class'; export default class Restart extends Command { constructor(client: Client) { diff --git a/src/commands/setlimit.ts b/src/commands/setlimit.ts index 60fd53b..e706b47 100644 --- a/src/commands/setlimit.ts +++ b/src/commands/setlimit.ts @@ -1,6 +1,5 @@ import { Message } from 'eris'; -import { Command } from '../class'; -import { Client } from '..'; +import { Client, Command } from '../class'; import SetLimit_RAM from './setlimit_ram'; export default class SetLimit extends Command { diff --git a/src/commands/setlimit_ram.ts b/src/commands/setlimit_ram.ts index 537f193..321216e 100644 --- a/src/commands/setlimit_ram.ts +++ b/src/commands/setlimit_ram.ts @@ -1,6 +1,5 @@ import { Message } from 'eris'; -import { Command } from '../class'; -import { Client } from '..'; +import { Client, Command } from '../class'; export default class SetLimit_RAM extends Command { constructor(client: Client) { diff --git a/src/commands/sysinfo.ts b/src/commands/sysinfo.ts index bf79eee..474a5eb 100644 --- a/src/commands/sysinfo.ts +++ b/src/commands/sysinfo.ts @@ -1,9 +1,8 @@ import moment from 'moment'; import { Message } from 'eris'; import os, { totalmem } from 'os'; -import { Command, RichEmbed } from '../class'; +import { Client, Command, RichEmbed } from '../class'; import { dataConversion } from '../functions'; -import { Client } from '..'; export default class SysInfo extends Command { constructor(client: Client) { diff --git a/src/commands/systemd.ts b/src/commands/systemd.ts index 643eb89..a157518 100644 --- a/src/commands/systemd.ts +++ b/src/commands/systemd.ts @@ -1,6 +1,5 @@ import { Message } from 'eris'; -import { Command } from '../class'; -import { Client } from '..'; +import { Client, Command } from '../class'; import SystemD_Linger from './systemd_linger'; export default class SystemD extends Command { diff --git a/src/commands/systemd_linger.ts b/src/commands/systemd_linger.ts index f77eb79..bf764f0 100644 --- a/src/commands/systemd_linger.ts +++ b/src/commands/systemd_linger.ts @@ -1,7 +1,6 @@ /* eslint-disable consistent-return */ import { Message } from 'eris'; -import { Command } from '../class'; -import { Client } from '..'; +import { Client, Command } from '../class'; export default class SystemdD_Linger extends Command { constructor(client: Client) { diff --git a/src/commands/tier.ts b/src/commands/tier.ts index c6cf932..d30de9e 100644 --- a/src/commands/tier.ts +++ b/src/commands/tier.ts @@ -1,6 +1,5 @@ import { Message } from 'eris'; -import { Client } from '..'; -import { Command, RichEmbed } from '../class'; +import { Client, Command, RichEmbed } from '../class'; export default class Tier extends Command { constructor(client: Client) { diff --git a/src/commands/unban.ts b/src/commands/unban.ts index fca5352..0e62126 100644 --- a/src/commands/unban.ts +++ b/src/commands/unban.ts @@ -1,6 +1,5 @@ import { Message } from 'eris'; -import { Client } from '..'; -import { Command } from '../class'; +import { Client, Command } from '../class'; export default class Unban extends Command { constructor(client: Client) { diff --git a/src/commands/unlock.ts b/src/commands/unlock.ts index e068f92..f4b26a8 100644 --- a/src/commands/unlock.ts +++ b/src/commands/unlock.ts @@ -1,6 +1,5 @@ import { Message } from 'eris'; -import { Client } from '..'; -import { Command } from '../class'; +import { Client, Command } from '../class'; export default class Unlock extends Command { constructor(client: Client) { diff --git a/src/commands/warn.ts b/src/commands/warn.ts index 7e421f9..607f5c9 100644 --- a/src/commands/warn.ts +++ b/src/commands/warn.ts @@ -1,6 +1,5 @@ import { Message } from 'eris'; -import { Client } from '..'; -import { Command } from '../class'; +import { Client, Command } from '../class'; export default class Warn extends Command { constructor(client: Client) { diff --git a/src/commands/whois.ts b/src/commands/whois.ts index 25a1de7..51a9b12 100644 --- a/src/commands/whois.ts +++ b/src/commands/whois.ts @@ -1,7 +1,6 @@ import moment from 'moment'; import { Message, GuildTextableChannel, Member, Role } from 'eris'; -import { Client } from '..'; -import { Command, RichEmbed } from '../class'; +import { Client, Command, RichEmbed } from '../class'; import { dataConversion } from '../functions'; import { AccountInterface } from '../models'; diff --git a/src/cscli/main.ts b/src/cscli/main.ts index bf864de..5a4c02f 100644 --- a/src/cscli/main.ts +++ b/src/cscli/main.ts @@ -3,7 +3,7 @@ import net from 'net'; import crypto from 'crypto'; import { promises as fs } from 'fs'; -import Client from '../Client'; +import Client from '../class/Client'; import { dataConversion } from '../functions'; export default class CSCLI { diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index 39684d7..21b303c 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -1,6 +1,5 @@ import { Message, TextChannel } from 'eris'; -import { Client } from '..'; -import Command from '../class/Command'; +import { Client } from '../class'; export default class { public client: Client @@ -25,7 +24,6 @@ export default class { if (resolved.cmd.permissions.roles) { for (const role of resolved.cmd.permissions.roles) { if (message.member && message.member.roles.includes(role)) { - // this.client.signale.debug(message.member.roles.includes(role)); hasRolePerms = true; break; } } diff --git a/src/functions/existingLimitsSetup.ts b/src/functions/existingLimitsSetup.ts index fb2e918..5946ae8 100644 --- a/src/functions/existingLimitsSetup.ts +++ b/src/functions/existingLimitsSetup.ts @@ -1,5 +1,5 @@ /* eslint-disable no-await-in-loop */ -import { Client } from '..'; +import { Client } from '../class'; export default async function existingLimitsSetup(client: Client): Promise { const tier1 = await client.db.Tier.findOne({ id: 1 }); diff --git a/src/functions/getUserByUid.ts b/src/functions/getUserByUid.ts index b56c148..f8033c3 100644 --- a/src/functions/getUserByUid.ts +++ b/src/functions/getUserByUid.ts @@ -1,4 +1,4 @@ -import { Client } from '..'; +import { Client } from '../class'; export default async function getUserByUid(client: Client, uid: number): Promise { const res = await client.util.exec(`${__dirname}/../bin/getUserByUid ${uid}`); diff --git a/src/functions/index.ts b/src/functions/index.ts index 6abf234..4c6b3f0 100644 --- a/src/functions/index.ts +++ b/src/functions/index.ts @@ -2,5 +2,4 @@ export { default as checkLock, clear as clearLock } from '../intervals/checkLock export { default as dataConversion } from './dataConversion'; export { default as existingLimitsSetup } from './existingLimitsSetup'; export { default as getUserByUid } from './getUserByUid'; -// export { default as checkSS, clear as clearSS } from './checkSS'; export { default as parseCertificate, Certificate } from './parseCertificate'; diff --git a/src/functions/parseCertificate.ts b/src/functions/parseCertificate.ts index f9d78ca..b474d5b 100644 --- a/src/functions/parseCertificate.ts +++ b/src/functions/parseCertificate.ts @@ -1,4 +1,4 @@ -import { Client } from '..'; +import { Client } from '../class'; export interface Certificate { subject: { diff --git a/src/index.ts b/src/index.ts index 4147cc3..a58f8ab 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -export { default as Client } from './class/Client'; +// export { default as Client } from './class/Client'; // eslint-disable-next-line import/no-unresolved export { default as config } from './config.json'; export * from './class'; diff --git a/src/intervals/checkLock.ts b/src/intervals/checkLock.ts index da8d33f..e3b0277 100644 --- a/src/intervals/checkLock.ts +++ b/src/intervals/checkLock.ts @@ -1,4 +1,4 @@ -import { Client } from '..'; +import { Client } from '../class'; let interval: NodeJS.Timeout; diff --git a/src/intervals/checkSS.ts b/src/intervals/checkSS.ts deleted file mode 100644 index 39cee9d..0000000 --- a/src/intervals/checkSS.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* eslint-disable consistent-return */ -/* eslint-disable no-unreachable */ -/* eslint-disable no-await-in-loop */ -import axios from 'axios'; -import { inspect } from 'util'; -import { Client } from '..'; - -let interval: NodeJS.Timeout; -export default function checkSS(client: Client) { - return; - interval = setInterval(async () => { - try { - const accounts = await client.db.Account.find(); - for (const { userID, homepath, hash } of accounts) { - try { - const Authorization = client.util.getAcctHash(homepath); - if (hash === null) throw new Error('Unable to locate auth file, homepath is probably incorrect'); - await axios({ - method: 'get', - url: 'https://api.securesign.org/account/details', - headers: { Authorization }, - }); - if (!hash) { - await client.db.Account.updateOne({ userID }, { $set: { hash: true } }); - client.getDMChannel(userID).then((channel) => channel.createMessage('Your SecureSign account has been automatically initialized via the SecureSign CLI.')).catch(); - } - } catch (error) { - if (!hash) return; - try { - const { status } = error.response; - if (status === 400 || status === 401 || status === 403 || status === 404) { - await client.db.Account.updateOne({ userID }, { $set: { hash: false } }); - client.getDMChannel(userID).then((channel) => channel.createMessage('Your SecureSign password has been reset - please reinitialize your SecureSign account. Run `=securesign init` for more information')).catch(); - } - } catch (e) { - throw error; - } - } - } - } catch (error) { - client.util.handleError(error); - } - }, 60000); - return interval; -} - -export function clear() { - clearTimeout(interval); -} diff --git a/src/intervals/checkStaffStatus.ts b/src/intervals/checkStaffStatus.ts index 6ea44e2..1b46eab 100644 --- a/src/intervals/checkStaffStatus.ts +++ b/src/intervals/checkStaffStatus.ts @@ -1,6 +1,5 @@ /* eslint-disable no-await-in-loop */ -import { Client } from '..'; -import { RichEmbed } from '../class'; +import { Client, RichEmbed } from '../class'; export default function checkStaffStatus(client: Client) { setInterval(async () => { diff --git a/src/intervals/memory.ts b/src/intervals/memory.ts index eea94ed..92ba296 100644 --- a/src/intervals/memory.ts +++ b/src/intervals/memory.ts @@ -1,8 +1,7 @@ /* eslint-disable no-useless-escape */ /* eslint-disable no-continue */ /* eslint-disable no-await-in-loop */ -import { Client } from '..'; -import { RichEmbed } from '../class'; +import { Client, RichEmbed } from '../class'; import { Tiers } from '../models'; const channelID = '691824484230889546'; diff --git a/src/intervals/storage.ts b/src/intervals/storage.ts index 488a578..e8ef484 100644 --- a/src/intervals/storage.ts +++ b/src/intervals/storage.ts @@ -1,7 +1,7 @@ /* eslint-disable no-await-in-loop */ // import fs from 'fs-extra'; import { spawn } from 'child_process'; -import { Client } from '..'; +import { Client } from '../class'; export default async function storage(client: Client) { let storageGo = spawn(`${__dirname}/../bin/storage`, [], { cwd: __dirname });