forked from engineering/cloudservices
lint
parent
8156657a95
commit
91099b6942
|
@ -3,6 +3,7 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "The official LOC Cloud Services system, this is a rewrite of the original version. ",
|
"description": "The official LOC Cloud Services system, this is a rewrite of the original version. ",
|
||||||
"main": "dist/Client.js",
|
"main": "dist/Client.js",
|
||||||
|
"scripts": { "lint": "eslint ./ --ext ts --fix" },
|
||||||
"author": "Library of Code sp-us Engineering Team",
|
"author": "Library of Code sp-us Engineering Team",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"private": false,
|
"private": false,
|
||||||
|
@ -20,6 +21,7 @@
|
||||||
"@typescript-eslint/parser": "^2.4.0",
|
"@typescript-eslint/parser": "^2.4.0",
|
||||||
"eslint": "^6.5.1",
|
"eslint": "^6.5.1",
|
||||||
"eslint-config-airbnb-base": "^14.0.0",
|
"eslint-config-airbnb-base": "^14.0.0",
|
||||||
"eslint-plugin-import": "^2.18.2"
|
"eslint-plugin-import": "^2.18.2",
|
||||||
|
"typescript": "^3.6.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import Account, { AccountInterface } from './models/Account.js';
|
||||||
import Moderation, { ModerationInterface } from './models/Moderation.js';
|
import Moderation, { ModerationInterface } from './models/Moderation.js';
|
||||||
import emojis from './stores/emojis.js';
|
import emojis from './stores/emojis.js';
|
||||||
import Util from './Util.js';
|
import Util from './Util.js';
|
||||||
import Command from './class/Command'
|
import Command from './class/Command';
|
||||||
|
|
||||||
|
|
||||||
export default class Client extends Eris.Client {
|
export default class Client extends Eris.Client {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { promisify } from 'util';
|
||||||
import childProcess from 'child_process';
|
import childProcess from 'child_process';
|
||||||
import nodemailer from 'nodemailer';
|
import nodemailer from 'nodemailer';
|
||||||
import Client from './Client';
|
import Client from './Client';
|
||||||
import Command from './class/Command'
|
import Command from './class/Command';
|
||||||
|
|
||||||
export default class Util {
|
export default class Util {
|
||||||
public client: Client;
|
public client: Client;
|
||||||
|
@ -30,11 +30,11 @@ export default class Util {
|
||||||
}
|
}
|
||||||
|
|
||||||
public resolveCommand(client: Client, command: string): Command {
|
public resolveCommand(client: Client, command: string): Command {
|
||||||
if (client.commands.has(command)) return client.commands.get(command)
|
if (client.commands.has(command)) return client.commands.get(command);
|
||||||
for (const cmd of client.commands.values()) {
|
for (const cmd of client.commands.values()) {
|
||||||
if (!cmd.aliases) continue
|
if (!cmd.aliases) continue;
|
||||||
for (const alias of cmd.aliases) {
|
for (const alias of cmd.aliases) {
|
||||||
if (command === alias.toLowerCase()) return cmd
|
if (command === alias.toLowerCase()) return cmd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,16 +13,20 @@ export default class Command {
|
||||||
aliases?: string[]
|
aliases?: string[]
|
||||||
|
|
||||||
client: Client
|
client: Client
|
||||||
|
|
||||||
permissions?: { roles?: string[], users?: string[] }
|
permissions?: { roles?: string[], users?: string[] }
|
||||||
|
|
||||||
guildOnly?: boolean
|
guildOnly?: boolean
|
||||||
|
|
||||||
public run(message: Message, args: string[]) {}
|
public run(message: Message, args: string[]) {}
|
||||||
|
|
||||||
constructor(client: Client) {
|
constructor(client: Client) {
|
||||||
this.name = 'None'
|
this.name = 'None';
|
||||||
this.description = 'No description given'
|
this.description = 'No description given';
|
||||||
this.usage = 'No usage given'
|
this.usage = 'No usage given';
|
||||||
this.enabled = false
|
this.enabled = false;
|
||||||
this.aliases = []
|
this.aliases = [];
|
||||||
this.guildOnly = true
|
this.guildOnly = true;
|
||||||
this.client = client
|
this.client = client;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
import Command from '../class/Command'
|
import { Message } from 'eris';
|
||||||
import Client from '../Client'
|
import Client from '../Client';
|
||||||
import { Message } from 'eris'
|
import Command from '../class/Command';
|
||||||
|
|
||||||
export default class Ping extends Command {
|
export default class Ping extends Command {
|
||||||
constructor(client: Client) {
|
constructor(client: Client) {
|
||||||
super(client)
|
super(client);
|
||||||
this.name = 'ping'
|
this.name = 'ping';
|
||||||
this.description = 'Pings the bot'
|
this.description = 'Pings the bot';
|
||||||
}
|
}
|
||||||
|
|
||||||
public async run(message: Message) {
|
public async run(message: Message) {
|
||||||
const clientStart: number = Date.now()
|
const clientStart: number = Date.now();
|
||||||
const msg: Message = await message.channel.createMessage('🏓 Pong!')
|
const msg: Message = await message.channel.createMessage('🏓 Pong!');
|
||||||
msg.edit(`🏓 Pong!\nClient: \`${Date.now() - clientStart}ms\`\nResponse: \`${msg.createdAt - message.createdAt}ms\``)
|
msg.edit(`🏓 Pong!\nClient: \`${Date.now() - clientStart}ms\`\nResponse: \`${msg.createdAt - message.createdAt}ms\``);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,30 +1,31 @@
|
||||||
import Client from '../Client'
|
import { Message, TextChannel } from 'eris';
|
||||||
import { prefix } from '../config.json'
|
import Client from '../Client';
|
||||||
import { Message, TextChannel } from 'eris'
|
import { prefix } from '../config.json';
|
||||||
import Util from '../Util'
|
import Util from '../Util';
|
||||||
import Command from '../class/Command'
|
import Command from '../class/Command';
|
||||||
|
|
||||||
export default class {
|
export default class {
|
||||||
client: Client
|
client: Client
|
||||||
|
|
||||||
constructor(client: Client) {
|
constructor(client: Client) {
|
||||||
this.client = client
|
this.client = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(message: Message) {
|
async run(message: Message) {
|
||||||
const noPrefix: string[] = message.content.slice(prefix.length).trim().split(/ +/g)
|
const noPrefix: string[] = message.content.slice(prefix.length).trim().split(/ +/g);
|
||||||
const command: string = noPrefix[0].toLowerCase()
|
const command: string = noPrefix[0].toLowerCase();
|
||||||
const resolved: Command = new Util().resolveCommand(this.client, command)
|
const resolved: Command = new Util().resolveCommand(this.client, command);
|
||||||
if (!resolved) return
|
if (!resolved) return;
|
||||||
if (resolved.guildOnly && !(message.channel instanceof TextChannel)) return
|
if (resolved.guildOnly && !(message.channel instanceof TextChannel)) return;
|
||||||
const hasUserPerms: boolean = resolved.permissions.users.includes(message.author.id)
|
const hasUserPerms: boolean = resolved.permissions.users.includes(message.author.id);
|
||||||
let hasRolePerms: boolean = false
|
let hasRolePerms: boolean = false;
|
||||||
for (const role of resolved.permissions.roles) {
|
for (const role of resolved.permissions.roles) {
|
||||||
if (message.member && message.member.roles.includes(role)) {
|
if (message.member && message.member.roles.includes(role)) {
|
||||||
hasRolePerms = true; break
|
hasRolePerms = true; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!hasRolePerms && !hasUserPerms) return
|
if (!hasRolePerms && !hasUserPerms) return;
|
||||||
const args: string[] = noPrefix.slice(1)
|
const args: string[] = noPrefix.slice(1);
|
||||||
resolved.run(message, args)
|
resolved.run(message, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -29,9 +29,9 @@ const Account: Schema = new Schema({
|
||||||
staff: Boolean,
|
staff: Boolean,
|
||||||
supervisor: Boolean,
|
supervisor: Boolean,
|
||||||
communityManager: Boolean,
|
communityManager: Boolean,
|
||||||
engineer: Boolean
|
engineer: Boolean,
|
||||||
},
|
},
|
||||||
root: Boolean
|
root: Boolean,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default model<AccountInterface>('Account', Account);
|
export default model<AccountInterface>('Account', Account);
|
|
@ -17,7 +17,7 @@ const Moderation: Schema = new Schema({
|
||||||
moderatorID: String,
|
moderatorID: String,
|
||||||
reason: String,
|
reason: String,
|
||||||
type: String,
|
type: String,
|
||||||
date: Date
|
date: Date,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default model<ModerationInterface>('Moderation', Moderation);
|
export default model<ModerationInterface>('Moderation', Moderation);
|
Loading…
Reference in New Issue