@@ 175,7 175,12 @@ async function play(clid: string, teamspeakID: string) {
try {
const data = await request(mutation, variables);
- message_channel(data.startQueue + " player(s) in queue.");
+ const players = data.startQueue;
+ message_channel(players + " player(s) in queue.");
+
+ if (players == 10) {
+ start_match();
+ }
} catch (e) {
const error = get_error(e);
switch (error) {
@@ 285,3 290,23 @@ async function finish_match(clid: string, teamspeakID: string, winner: string) {
}
}
}
+
+async function start_match() {
+ const mutation = gql`
+ mutation {
+ createMatch
+ }
+ `;
+
+ try {
+ const data = await request(mutation);
+ message_channel("Started match.");
+ } catch (e) {
+ const error = get_error(e);
+ switch (error) {
+ default:
+ console.error(error);
+ break;
+ }
+ }
+}