Simp-O-Matic

Dumb Discord bot in TS.
git clone git://git.knutsen.co/Simp-O-Matic
Log | Files | Refs | README | LICENSE

commit 6e04d8db16828ec6b46443b498126d02a379ebd5
parent 29d0aea738a89fa56634aeee6b091a70cb45f9e0
Author: Demonstrandum <moi@knutsen.co>
Date:   Wed, 20 May 2020 23:56:05 +0100

UNFUCK DANNY'S DISREGARD FOR TYPES.

Diffstat:
Mlib/default.ts | 6+++---
Mlib/extensions.ts | 27+++++++++++++++++++++------
Mlib/main.ts | 7+++++--
3 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/lib/default.ts b/lib/default.ts @@ -2,16 +2,16 @@ /// and to act as a reference to how the config shall be /// laid out. All fields are accounted for here. -const DEFAULT_GUILD_CONFIG = { +const DEFAULT_GUILD_CONFIG : Types.Config = { main_channel: null, system_channel: null, whitelistchannels: [], - stats : { + stats: { actions: { rape: [] }, commands: { - + rape: 0 } }, pp_sizes: { diff --git a/lib/extensions.ts b/lib/extensions.ts @@ -7,7 +7,7 @@ declare global { HELP_SOURCE: string, HELP_KEY: string, GIT_URL: string, HELP_MESSAGES: string[], HELP_SECTIONS: string[] , ALL_HELP: string[], - CONFIG: any, SECRETS: any, KNOWN_COMMANDS: string[], + CONFIG: Types.Config, SECRETS: any, KNOWN_COMMANDS: string[], expand_alias: (operator: string, args: string[], message: Message) => string, main: SimpOMatic; }; @@ -25,14 +25,29 @@ declare global { speech?: boolean }; - type Config = { + export type Stats = { + actions: { + [key: string]: any + // Any for now, Danny should pick the correct type. + }, + commands: { + [key: string]: number + } + }; + + export type Config = { main_channel: string, system_channel: string, whitelistchannels: string[], - pp_sizes: { [key: string]: number } + pp_sizes: { + [key: string]: number + }, cron_jobs: any[], - cron_interval: number; - weather_locations: { [key: string]: string }, + cron_interval: number, + weather_locations: { + [key: string]: string + }, + stats: Stats, commands: { prefix: string, max_history: number, @@ -65,7 +80,7 @@ declare global { tag: string, permissions: number, lang: 'en' | 'en-us' | 'en-gb', - guilds: { [key: string]: any } + guilds: { [key: string]: Config } }; } diff --git a/lib/main.ts b/lib/main.ts @@ -293,11 +293,14 @@ Would you like to slow down a little?`.squeeze()); + '\n**Fix this immediately.**'); return; } + operator = operator.toLowerCase(); console.log('Received command:', [operator, args]); - CONFIG.stats = CONFIG.stats || {}; + CONFIG.stats = CONFIG.stats || <Types.Stats>{}; CONFIG.stats.commands = CONFIG.stats.commands || {}; - CONFIG.stats.commands[operator] = ++CONFIG.stats.commands[operator] || 0; + CONFIG.stats.commands[operator] = + ++CONFIG.stats.commands[operator] || 1; + const homescope : HomeScope = { // Basic 'home-scope' is passed in. message, args, HELP_SOURCE, HELP_KEY, GIT_URL,