Simp-O-Matic

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

commit b1cd7920c4c2013f163c758c1c9cb7f4f447bbf3
parent 0067b97092ca1b1acd42e0779c9be33467f6ed9f
Author: Demonstrandum <moi@knutsen.co>
Date:   Fri, 22 May 2020 14:44:11 +0100

Add backend for console interface.

Diffstat:
Mlib/main.ts | 20+++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/lib/main.ts b/lib/main.ts @@ -181,7 +181,8 @@ export class SimpOMatic { || member.user.tag.split('#').first())); } }); - + + // TODO: In web-server, check for correct secret. // Send messages on web-hooks. server(GLOBAL_CONFIG, body => { if (body.ref === "refs/heads/master" || body.action) { @@ -204,6 +205,23 @@ export class SimpOMatic { .setTitle("Star Added!"); system_message(client, star_embed); } + } else if (body.console === true) { + const send_message = (msg: string, guild?) => { + if (guild + && GLOBAL_CONFIG.guilds.hasOwnProperty(guild) + && GLOBAL_CONFIG.guilds[guild].system_channel) { + client.channels + .fetch(GLOBAL_CONFIG.guilds[guild].system_channel) + .then((c: TextChannel) => c.send(msg)); + } else { + system_message(client, msg); + } + } + if (body.message) { + send_message(body.message, body.guild); + } else if (body.command) { + // TODO? + } } else { system_message(client, "Received unknown data:\n```json\n" + JSON.stringify(body, null, 4).slice(0, 1930)