@@ 42,6 42,12 @@ teamspeak.on("textmessage", (ev) => {
case "!register":
register(clid, teamspeakID, argv[1]);
break;
+ case "!play":
+ play(clid, teamspeakID);
+ break;
+ case "!cancel":
+ cancel(clid, teamspeakID);
+ break;
}
});
@@ 124,3 130,51 @@ async function register(clid: string, teamspeakID: string, steamID: string) {
}
}
}
+
+async function play(clid: string, teamspeakID: string) {
+ const mutation = gql`
+ mutation ($teamspeakID: String!) {
+ startQueue(teamspeakID: $teamspeakID)
+ }
+ `;
+ const variables = { teamspeakID: teamspeakID };
+
+ try {
+ const data = await request(mutation, variables);
+ message_channel(data.startQueue + " player(s) in queue.");
+ } catch (e) {
+ const error = get_error(e);
+ switch (error) {
+ case "already in queue":
+ message(clid, "Already in queue.");
+ break;
+ default:
+ console.error(error);
+ break;
+ }
+ }
+}
+
+async function cancel(clid: string, teamspeakID: string) {
+ const mutation = gql`
+ mutation ($teamspeakID: String!) {
+ cancelQueue(teamspeakID: $teamspeakID)
+ }
+ `;
+ const variables = { teamspeakID: teamspeakID };
+
+ try {
+ const data = await request(mutation, variables);
+ message_channel(data.cancelQueue + " player(s) in queue.");
+ } catch (e) {
+ const error = get_error(e);
+ switch (error) {
+ case "user not in queue":
+ message(clid, "You are not in queue.");
+ break;
+ default:
+ console.error(error);
+ break;
+ }
+ }
+}