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