Initial Commit

merge-requests/1/merge
Matthew R 2019-10-14 15:46:10 -04:00
commit 9baaa20b00
No known key found for this signature in database
GPG Key ID: 97CA005641E9054C
6 changed files with 216 additions and 0 deletions

20
package.json Normal file
View File

@ -0,0 +1,20 @@
{
"name": "cloudservices-rewrite",
"version": "1.0.0",
"description": "The official LOC Cloud Services system, this is a rewrite of the original version. ",
"main": "dist/Client.js",
"author": "Library of Code sp-us Engineering Team",
"license": "MIT",
"private": false,
"dependencies": {
"eris": "^0.10.1",
"fs-extra": "^8.1.0",
"mongoose": "^5.7.4",
"nodemailer": "^6.3.1"
},
"devDependencies": {
"@types/fs-extra": "^8.0.0",
"@types/mongoose": "^5.5.20",
"@types/nodemailer": "^6.2.1"
}
}

52
src/Client.ts Normal file
View File

@ -0,0 +1,52 @@
import Eris from 'eris';
import mongoose from 'mongoose';
import fs from 'fs-extra';
import path from 'path';
import config from './config.json';
export default class Client extends Eris.Client {
public commands: Map<string, any>;
public aliases: Map<string, string>;
constructor() {
super(config.token);
this.commands = new Map();
this.aliases = new Map();
}
public loadCommand(commandPath: string) {
// eslint-disable-next-line no-useless-catch
try {
const command = new (require(commandPath))(this);
if (command.init) { command.init(this); }
this.commands.set(command.help.name, command);
if (command.config.aliases) {
command.config.aliases.forEach(alias => {
this.aliases.set(alias, command.help.name);
});
}
return `Successfully loaded ${command.help.name}.`;
} catch (err) { throw err; }
}
public async init() {
const evtFiles = await fs.readdir('./events/');
const commands = await fs.readdir(path.join(__dirname, './commands/'));
commands.forEach(command => {
const response = this.loadCommand(`./commands/${command}`);
if (response) console.log(response);
});
console.log(`Loading a total of ${evtFiles.length} events.`);
evtFiles.forEach(file => {
const eventName = file.split('.')[0];
console.log(`Loading Event: ${eventName}`);
const event = new (require(`./events/${file}`))(this);
this.on(eventName, (...args) => event.run(...args));
delete require.cache[require.resolve(`./events/${file}`)];
});
this.connect();
}
}

20
src/Util.ts Normal file
View File

@ -0,0 +1,20 @@
import { promisify } from 'util';
import childProcess from 'child_process';
import nodemailer from 'nodemailer';
export default class Util {
constructor() {}
public async exec(command: string): Promise<string> {
const ex = promisify(childProcess.exec);
let result: string;
try {
const res = await ex(command);
if (res.stderr) result = res.stderr;
else result = res.stdout;
} catch (err) {
throw err;
}
return result;
}
}

37
src/models/Account.ts Normal file
View File

@ -0,0 +1,37 @@
import { Document, Schema, model } from 'mongoose';
export interface AccountInterface extends Document {
account: string,
userID: string,
emailAddress: string,
createdBy: string,
createdAt: Date,
locked: boolean,
permissions: {
support: boolean,
staff: boolean,
supervisor: boolean,
communityManager: boolean,
engineer: boolean
},
root: boolean
}
const Account: Schema = new Schema({
account: String,
userID: String,
emailAddress: String,
createdBy: String,
createdAt: Date,
locked: Boolean,
permissions: {
support: Boolean,
staff: Boolean,
supervisor: Boolean,
communityManager: Boolean,
engineer: Boolean
},
root: Boolean
});
export default model<AccountInterface>('Account', Account);

23
src/models/Moderation.ts Normal file
View File

@ -0,0 +1,23 @@
import { Document, Schema, model } from 'mongoose';
export interface ModerationInterface extends Document {
account: string,
userID: string,
logID: string,
moderatorID: string,
reason: string,
type: string,
date: string
}
const Moderation: Schema = new Schema({
account: String,
userID: String,
logID: Number,
moderatorID: String,
reason: String,
type: String,
date: Date
});
export default model<ModerationInterface>('Moderation', Moderation);

64
tsconfig.json Normal file
View File

@ -0,0 +1,64 @@
{
"compilerOptions": {
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "ES2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
"declaration": false, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./dist", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
"removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": false, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
"resolveJsonModule": true,
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
}
}