From c6018880b51784016a4b21470945b081c7bf4cd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorben=20G=C3=BCnther?= Date: Thu, 11 Nov 2021 12:32:35 +0100 Subject: [PATCH] Add !help command --- app.ts | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/app.ts b/app.ts index b8e2ba0..4c49097 100644 --- a/app.ts +++ b/app.ts @@ -16,6 +16,23 @@ const teamspeak = new TeamSpeak({ nickname: "10Man", }); +let commands = new Map([ + ["!hello", "Say hello"], + ["!elo", "Show your elo"], + [ + "!register ", + "Register with your STEAMID64 (https://steamid.io/)", + ], + ["!play", "Go into the queue"], + ["!cancel", "Cancel you queue"], + ["!help", "Show this help text"], +]); + +let admin_commands = new Map([ + ["!cancelMatch", "Cancel the ongoing match"], + ["!finish ", "Finish the ongoing match with WINNER (TEAM1, TEAM2)"], +]); + teamspeak.on("ready", async () => { const whoami = await teamspeak.whoami(); const channel = await teamspeak.channelFind("10 Man"); @@ -54,6 +71,9 @@ teamspeak.on("textmessage", (ev) => { case "!finish": finish_match(clid, teamspeakID, argv[1]); break; + case "!help": + help(clid, teamspeakID); + break; } }); @@ -382,3 +402,22 @@ async function move_clients(back: boolean = false) { } } } + +async function help(clid: string, teamspeakID: string) { + const admin = await is_admin(clid, teamspeakID); + var msg = ""; + + if (admin) { + msg += "\nAdmin only commands:\n"; + for (let entry of admin_commands) { + msg += entry[0] + ": " + entry[1] + "\n"; + } + } + + msg += "\nUser commands:\n"; + for (let entry of commands) { + msg += entry[0] + ": " + entry[1] + "\n"; + } + + teamspeak.sendTextMessage(clid, 1, msg); +} -- 2.44.0