@@ 49,6 49,16 @@ function message(clid: string, msg: string) {
teamspeak.sendTextMessage(clid, 1, msg);
}
+function message_channel(msg: string) {
+ teamspeak.channelFind("10 Man").then((channel) => {
+ teamspeak.sendTextMessage(channel[0].cid, 2, msg);
+ });
+}
+
+function get_error(e: unknown): string {
+ return JSON.parse(JSON.stringify(e)).response.errors[0].message;
+}
+
async function request(query: string, variables: Variables): Promise<any> {
const endpoint = process.env.ENDPOINT!;
const graphQLClient = new GraphQLClient(endpoint, {
@@ 73,7 83,7 @@ async function elo(clid: string, teamspeakID: string) {
const data = await request(query, variables);
message(clid, "Elo: " + data.userByTS.elo);
} catch (e) {
- const error = JSON.parse(JSON.stringify(e)).response.errors[0].message;
+ const error = get_error(e);
switch (error) {
case "no result":
message(clid, "You are not registered with this teamspeakID.");
@@ 97,7 107,7 @@ async function register(clid: string, teamspeakID: string, steamID: string) {
const data = await request(mutation, variables);
message(clid, "Registered successfully.");
} catch (e) {
- const error = JSON.parse(JSON.stringify(e)).response.errors[0].message;
+ const error = get_error(e);
switch (error) {
case "not unique":
message(