Kit Kasune 2 weeks ago
parent 0bd7646b40
commit c2be6001fb
  1. 22
      src/handle/startup/run/setutils.js
  2. 33
      src/handle/startup/run/verifyconfig.js
  3. 64
      src/util/ts/src/command.ts

@ -1,22 +0,0 @@
module.exports = client => {
client.utils = {}; //small collection of basic string manipulation utilities so prettier strings are easier
//pluralize most strings based on a number
client.utils.s = num => num === 1 ? '' : 's';
//pluralize but pass in the text to make plural
client.utils.as = (num, text) => `${text}${client.utils.s(num)}`;
// "a" or "an" based on the provided string, caps to begin with capital letter
client.utils.an = (text, caps) => `${caps ? 'A' : 'a'}${['a', 'e', 'i', 'o', 'u'].includes(text.toLowerCase().trim().slice(0, 1)) ? 'n' : ''} ${text}`;
//capitalize a string automatically, "a" if rest of string should be automatically lowercased
client.utils.c = (text, a=true) => `${text.slice(0, 1).toUpperCase()}${a ? text.slice(1).toLowerCase() : text.slice(1)}`;
//split text into words and autocap each one
client.utils.ca = (text, a=true) => text.split(/\s+/gm).map(t => client.utils.c(t, a)).join(" ");
//format a moment-presice-range object
client.utils.sm = (mpr, ago=true) => `${mpr.years ? `${mpr.years} year${client.utils.s(mpr.years)} ` : ''}${mpr.months ? `${mpr.months} month${client.utils.s(mpr.months)} ` : ''}${mpr.days} day${client.utils.s(mpr.days)}${ago ? ' ago' : ''}`;
//add a grammatically correct possessive indicator to the end of a word/string
client.utils.p = (text) => text.endsWith('s') ? "'" : "'s";
//possessivise but pass in the text to possessivize
client.utils.ps = (text) => `${text}${client.utils.p(text)}`;
//random element of array
client.utils.gr = list => list[Math.floor(Math.random() * list.length)];
};

@ -1,33 +0,0 @@
const defaultConfig = {
bot: {
name: "Cool Bot",
consoleName: "CBOT",
prefix: "cb.",
devPrefix: "cb!"
},
embed: {
colors: {
base: "c375f0",
success: "23d534",
fail: "d52334"
}
},
log: {
suffix: ">>",
defaultLevel: 1,
colors: {
error: "redBright",
warn: "yellowBright",
success: "greenBright",
notice: "#8521a0",
primary: "blue",
secondary: "green",
altprimary: "blueBright",
altsecondary: "greenBright"
}
}
}
module.exports = client => {
};

@ -1,64 +0,0 @@
import {Embed, Client, Message} from "discord.js";
export class Command {
name: string;
meta: CommandMeta;
help: Embed | string;
constructor(name: string, meta: CommandMeta, help: Embed | string) {
this.name = name;
this.meta = meta;
this.help = help;
}
}
export class SubCommand {
}
export class TextCommand extends Command {
private _execute: (client: Client, message: Message, args: string[], cmd: TextCommandCmdArg) => void | any;
subCommandsKey: Map<string, string>;
subCommands: Map<string, SubCommand>;
enabled: boolean = true;
constructor(name: string, meta: CommandMeta, help: Embed | string, execute: (client: Client, message: Message, args: string[], cmd: TextCommandCmdArg) => void | any, subCommands?: SubCommand[]) {
super(name, meta, help);
this._execute = execute;
if (subCommands && Array.isArray(subCommands) && subCommands.length) {
//
}
}
public execute(client: Client, message: Message, args: string[], cmd: TextCommandCmdArg): void | any {
if (!this.enabled) {return;} //TODO command return output logging flag
return this._execute(client, message, args, cmd);
}
public toggle(): void {this.enabled = !this.enabled;}
public enable(): void {this.enabled = true;}
public disable(): void {this.enabled = false;}
}
export class SlashCommand extends Command {}
export interface CommandMeta {
category: string,
description: string,
syntax: string,
extra: string | null
}
export interface TextCommandCmdArg {
msg: string,
name: string,
prefix: string,
args: string[]
}
Loading…
Cancel
Save