moons-ta-client 1.1.6 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -73,7 +73,10 @@ class Response$Type extends MessageType {
73
73
  { no: 17, name: "load_song", kind: "message", oneof: "details", T: () => Response_LoadSong },
74
74
  { no: 18, name: "preload_image_for_stream_sync", kind: "message", oneof: "details", T: () => Response_PreloadImageForStreamSync },
75
75
  { no: 19, name: "show_prompt", kind: "message", oneof: "details", T: () => Response_ShowPrompt },
76
- { no: 20, name: "remaining_attempts", kind: "message", oneof: "details", T: () => Response_RemainingAttempts }
76
+ { no: 20, name: "remaining_attempts", kind: "message", oneof: "details", T: () => Response_RemainingAttempts },
77
+ { no: 26, name: "get_bot_tokens_for_user", kind: "message", oneof: "details", T: () => Response_GetBotTokensForUser },
78
+ { no: 27, name: "generate_bot_token", kind: "message", oneof: "details", T: () => Response_GenerateBotToken },
79
+ { no: 28, name: "revoke_bot_token", kind: "message", oneof: "details", T: () => Response_RevokeBotToken }
77
80
  ]);
78
81
  }
79
82
  create(value) {
@@ -232,6 +235,24 @@ class Response$Type extends MessageType {
232
235
  remainingAttempts: Response_RemainingAttempts.internalBinaryRead(reader, reader.uint32(), options, message.details.remainingAttempts)
233
236
  };
234
237
  break;
238
+ case /* proto.packets.Response.GetBotTokensForUser get_bot_tokens_for_user */ 26:
239
+ message.details = {
240
+ oneofKind: "getBotTokensForUser",
241
+ getBotTokensForUser: Response_GetBotTokensForUser.internalBinaryRead(reader, reader.uint32(), options, message.details.getBotTokensForUser)
242
+ };
243
+ break;
244
+ case /* proto.packets.Response.GenerateBotToken generate_bot_token */ 27:
245
+ message.details = {
246
+ oneofKind: "generateBotToken",
247
+ generateBotToken: Response_GenerateBotToken.internalBinaryRead(reader, reader.uint32(), options, message.details.generateBotToken)
248
+ };
249
+ break;
250
+ case /* proto.packets.Response.RevokeBotToken revoke_bot_token */ 28:
251
+ message.details = {
252
+ oneofKind: "revokeBotToken",
253
+ revokeBotToken: Response_RevokeBotToken.internalBinaryRead(reader, reader.uint32(), options, message.details.revokeBotToken)
254
+ };
255
+ break;
235
256
  default:
236
257
  let u = options.readUnknownField;
237
258
  if (u === "throw")
@@ -319,6 +340,15 @@ class Response$Type extends MessageType {
319
340
  /* proto.packets.Response.RemainingAttempts remaining_attempts = 20; */
320
341
  if (message.details.oneofKind === "remainingAttempts")
321
342
  Response_RemainingAttempts.internalBinaryWrite(message.details.remainingAttempts, writer.tag(20, WireType.LengthDelimited).fork(), options).join();
343
+ /* proto.packets.Response.GetBotTokensForUser get_bot_tokens_for_user = 26; */
344
+ if (message.details.oneofKind === "getBotTokensForUser")
345
+ Response_GetBotTokensForUser.internalBinaryWrite(message.details.getBotTokensForUser, writer.tag(26, WireType.LengthDelimited).fork(), options).join();
346
+ /* proto.packets.Response.GenerateBotToken generate_bot_token = 27; */
347
+ if (message.details.oneofKind === "generateBotToken")
348
+ Response_GenerateBotToken.internalBinaryWrite(message.details.generateBotToken, writer.tag(27, WireType.LengthDelimited).fork(), options).join();
349
+ /* proto.packets.Response.RevokeBotToken revoke_bot_token = 28; */
350
+ if (message.details.oneofKind === "revokeBotToken")
351
+ Response_RevokeBotToken.internalBinaryWrite(message.details.revokeBotToken, writer.tag(28, WireType.LengthDelimited).fork(), options).join();
322
352
  let u = options.writeUnknownFields;
323
353
  if (u !== false)
324
354
  (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -1667,3 +1697,205 @@ class Response_RemainingAttempts$Type extends MessageType {
1667
1697
  * @generated MessageType for protobuf message proto.packets.Response.RemainingAttempts
1668
1698
  */
1669
1699
  export const Response_RemainingAttempts = new Response_RemainingAttempts$Type();
1700
+ // @generated message type with reflection information, may provide speed optimized methods
1701
+ class Response_GetBotTokensForUser$Type extends MessageType {
1702
+ constructor() {
1703
+ super("proto.packets.Response.GetBotTokensForUser", [
1704
+ { no: 1, name: "bot_users", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => Response_GetBotTokensForUser_BotUser }
1705
+ ]);
1706
+ }
1707
+ create(value) {
1708
+ const message = { botUsers: [] };
1709
+ globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
1710
+ if (value !== undefined)
1711
+ reflectionMergePartial(this, message, value);
1712
+ return message;
1713
+ }
1714
+ internalBinaryRead(reader, length, options, target) {
1715
+ let message = target ?? this.create(), end = reader.pos + length;
1716
+ while (reader.pos < end) {
1717
+ let [fieldNo, wireType] = reader.tag();
1718
+ switch (fieldNo) {
1719
+ case /* repeated proto.packets.Response.GetBotTokensForUser.BotUser bot_users */ 1:
1720
+ message.botUsers.push(Response_GetBotTokensForUser_BotUser.internalBinaryRead(reader, reader.uint32(), options));
1721
+ break;
1722
+ default:
1723
+ let u = options.readUnknownField;
1724
+ if (u === "throw")
1725
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
1726
+ let d = reader.skip(wireType);
1727
+ if (u !== false)
1728
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
1729
+ }
1730
+ }
1731
+ return message;
1732
+ }
1733
+ internalBinaryWrite(message, writer, options) {
1734
+ /* repeated proto.packets.Response.GetBotTokensForUser.BotUser bot_users = 1; */
1735
+ for (let i = 0; i < message.botUsers.length; i++)
1736
+ Response_GetBotTokensForUser_BotUser.internalBinaryWrite(message.botUsers[i], writer.tag(1, WireType.LengthDelimited).fork(), options).join();
1737
+ let u = options.writeUnknownFields;
1738
+ if (u !== false)
1739
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
1740
+ return writer;
1741
+ }
1742
+ }
1743
+ /**
1744
+ * @generated MessageType for protobuf message proto.packets.Response.GetBotTokensForUser
1745
+ */
1746
+ export const Response_GetBotTokensForUser = new Response_GetBotTokensForUser$Type();
1747
+ // @generated message type with reflection information, may provide speed optimized methods
1748
+ class Response_GetBotTokensForUser_BotUser$Type extends MessageType {
1749
+ constructor() {
1750
+ super("proto.packets.Response.GetBotTokensForUser.BotUser", [
1751
+ { no: 1, name: "guid", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
1752
+ { no: 2, name: "username", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
1753
+ { no: 3, name: "owner_discord_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
1754
+ ]);
1755
+ }
1756
+ create(value) {
1757
+ const message = { guid: "", username: "", ownerDiscordId: "" };
1758
+ globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
1759
+ if (value !== undefined)
1760
+ reflectionMergePartial(this, message, value);
1761
+ return message;
1762
+ }
1763
+ internalBinaryRead(reader, length, options, target) {
1764
+ let message = target ?? this.create(), end = reader.pos + length;
1765
+ while (reader.pos < end) {
1766
+ let [fieldNo, wireType] = reader.tag();
1767
+ switch (fieldNo) {
1768
+ case /* string guid */ 1:
1769
+ message.guid = reader.string();
1770
+ break;
1771
+ case /* string username */ 2:
1772
+ message.username = reader.string();
1773
+ break;
1774
+ case /* string owner_discord_id */ 3:
1775
+ message.ownerDiscordId = reader.string();
1776
+ break;
1777
+ default:
1778
+ let u = options.readUnknownField;
1779
+ if (u === "throw")
1780
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
1781
+ let d = reader.skip(wireType);
1782
+ if (u !== false)
1783
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
1784
+ }
1785
+ }
1786
+ return message;
1787
+ }
1788
+ internalBinaryWrite(message, writer, options) {
1789
+ /* string guid = 1; */
1790
+ if (message.guid !== "")
1791
+ writer.tag(1, WireType.LengthDelimited).string(message.guid);
1792
+ /* string username = 2; */
1793
+ if (message.username !== "")
1794
+ writer.tag(2, WireType.LengthDelimited).string(message.username);
1795
+ /* string owner_discord_id = 3; */
1796
+ if (message.ownerDiscordId !== "")
1797
+ writer.tag(3, WireType.LengthDelimited).string(message.ownerDiscordId);
1798
+ let u = options.writeUnknownFields;
1799
+ if (u !== false)
1800
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
1801
+ return writer;
1802
+ }
1803
+ }
1804
+ /**
1805
+ * @generated MessageType for protobuf message proto.packets.Response.GetBotTokensForUser.BotUser
1806
+ */
1807
+ export const Response_GetBotTokensForUser_BotUser = new Response_GetBotTokensForUser_BotUser$Type();
1808
+ // @generated message type with reflection information, may provide speed optimized methods
1809
+ class Response_GenerateBotToken$Type extends MessageType {
1810
+ constructor() {
1811
+ super("proto.packets.Response.GenerateBotToken", [
1812
+ { no: 1, name: "bot_token", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
1813
+ ]);
1814
+ }
1815
+ create(value) {
1816
+ const message = { botToken: "" };
1817
+ globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
1818
+ if (value !== undefined)
1819
+ reflectionMergePartial(this, message, value);
1820
+ return message;
1821
+ }
1822
+ internalBinaryRead(reader, length, options, target) {
1823
+ let message = target ?? this.create(), end = reader.pos + length;
1824
+ while (reader.pos < end) {
1825
+ let [fieldNo, wireType] = reader.tag();
1826
+ switch (fieldNo) {
1827
+ case /* string bot_token */ 1:
1828
+ message.botToken = reader.string();
1829
+ break;
1830
+ default:
1831
+ let u = options.readUnknownField;
1832
+ if (u === "throw")
1833
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
1834
+ let d = reader.skip(wireType);
1835
+ if (u !== false)
1836
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
1837
+ }
1838
+ }
1839
+ return message;
1840
+ }
1841
+ internalBinaryWrite(message, writer, options) {
1842
+ /* string bot_token = 1; */
1843
+ if (message.botToken !== "")
1844
+ writer.tag(1, WireType.LengthDelimited).string(message.botToken);
1845
+ let u = options.writeUnknownFields;
1846
+ if (u !== false)
1847
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
1848
+ return writer;
1849
+ }
1850
+ }
1851
+ /**
1852
+ * @generated MessageType for protobuf message proto.packets.Response.GenerateBotToken
1853
+ */
1854
+ export const Response_GenerateBotToken = new Response_GenerateBotToken$Type();
1855
+ // @generated message type with reflection information, may provide speed optimized methods
1856
+ class Response_RevokeBotToken$Type extends MessageType {
1857
+ constructor() {
1858
+ super("proto.packets.Response.RevokeBotToken", [
1859
+ { no: 1, name: "message", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
1860
+ ]);
1861
+ }
1862
+ create(value) {
1863
+ const message = { message: "" };
1864
+ globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
1865
+ if (value !== undefined)
1866
+ reflectionMergePartial(this, message, value);
1867
+ return message;
1868
+ }
1869
+ internalBinaryRead(reader, length, options, target) {
1870
+ let message = target ?? this.create(), end = reader.pos + length;
1871
+ while (reader.pos < end) {
1872
+ let [fieldNo, wireType] = reader.tag();
1873
+ switch (fieldNo) {
1874
+ case /* string message */ 1:
1875
+ message.message = reader.string();
1876
+ break;
1877
+ default:
1878
+ let u = options.readUnknownField;
1879
+ if (u === "throw")
1880
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
1881
+ let d = reader.skip(wireType);
1882
+ if (u !== false)
1883
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
1884
+ }
1885
+ }
1886
+ return message;
1887
+ }
1888
+ internalBinaryWrite(message, writer, options) {
1889
+ /* string message = 1; */
1890
+ if (message.message !== "")
1891
+ writer.tag(1, WireType.LengthDelimited).string(message.message);
1892
+ let u = options.writeUnknownFields;
1893
+ if (u !== false)
1894
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
1895
+ return writer;
1896
+ }
1897
+ }
1898
+ /**
1899
+ * @generated MessageType for protobuf message proto.packets.Response.RevokeBotToken
1900
+ */
1901
+ export const Response_RevokeBotToken = new Response_RevokeBotToken$Type();
@@ -60,6 +60,8 @@ export declare class TAClient extends CustomEventEmitter<TAClientEvents> {
60
60
  sendResponse(response: Response, to?: string[]): Promise<void>;
61
61
  playSong: (gameplayParameters: GameplayParameters, userIds: string[]) => void;
62
62
  returnToMenu: (userIds: string[]) => void;
63
+ flipColors: (userIds: string[]) => void;
64
+ flipHands: (userIds: string[]) => void;
63
65
  showLoadedImage: (userIds: string[]) => void;
64
66
  delayTestFinished: (userIds: string[]) => void;
65
67
  joinTournament: (tournamentId: string) => Promise<Response>;
@@ -89,6 +91,9 @@ export declare class TAClient extends CustomEventEmitter<TAClientEvents> {
89
91
  removeAuthorizedUser: (tournamentId: string, discordId: string) => Promise<Response>;
90
92
  getAuthorizedUsers: (tournamentId: string) => Promise<Response>;
91
93
  getDiscordInfo: (tournamentId: string, discordId: string) => Promise<Response>;
94
+ getBotTokensForUser: (ownerDiscordId: string) => Promise<Response>;
95
+ generateBotToken: (username: string) => Promise<Response>;
96
+ revokeBotToken: (botTokenGuid: string) => Promise<Response>;
92
97
  createTournament: (tournament: Tournament) => Promise<Response>;
93
98
  setTournamentName: (tournamentId: string, tournamentName: string) => Promise<Response>;
94
99
  setTournamentImage: (tournamentId: string, tournamentImage: Uint8Array) => Promise<Response>;
@@ -3,6 +3,7 @@ import { CustomEventEmitter } from "./custom-event-emitter.js";
3
3
  import { v4 as uuidv4 } from "uuid";
4
4
  import { StateManager } from "./state-manager.js";
5
5
  import { Response_ResponseType, } from "./models/responses.js";
6
+ import { Command_ModifyGameplay_Modifier } from "./models/commands.js";
6
7
  import { versionCode } from "./constants.js";
7
8
  import WebSocket from "ws";
8
9
  // Created by Moon on 6/12/2022
@@ -257,6 +258,26 @@ export class TAClient extends CustomEventEmitter {
257
258
  },
258
259
  }, userIds);
259
260
  };
261
+ flipColors = (userIds) => {
262
+ this.sendCommand({
263
+ type: {
264
+ oneofKind: "modifyGameplay",
265
+ modifyGameplay: {
266
+ modifier: Command_ModifyGameplay_Modifier.InvertColors
267
+ },
268
+ },
269
+ }, userIds);
270
+ };
271
+ flipHands = (userIds) => {
272
+ this.sendCommand({
273
+ type: {
274
+ oneofKind: "modifyGameplay",
275
+ modifyGameplay: {
276
+ modifier: Command_ModifyGameplay_Modifier.InvertHandedness
277
+ },
278
+ },
279
+ }, userIds);
280
+ };
260
281
  showLoadedImage = (userIds) => {
261
282
  this.sendCommand({
262
283
  type: {
@@ -853,6 +874,48 @@ export class TAClient extends CustomEventEmitter {
853
874
  }
854
875
  return response[0].response;
855
876
  };
877
+ getBotTokensForUser = async (ownerDiscordId) => {
878
+ const response = await this.sendRequest({
879
+ type: {
880
+ oneofKind: "getBotTokensForUser",
881
+ getBotTokensForUser: {
882
+ ownerDiscordId
883
+ },
884
+ },
885
+ });
886
+ if (response.length <= 0) {
887
+ throw new Error("Server timed out");
888
+ }
889
+ return response[0].response;
890
+ };
891
+ generateBotToken = async (username) => {
892
+ const response = await this.sendRequest({
893
+ type: {
894
+ oneofKind: "generateBotToken",
895
+ generateBotToken: {
896
+ username
897
+ },
898
+ },
899
+ });
900
+ if (response.length <= 0) {
901
+ throw new Error("Server timed out");
902
+ }
903
+ return response[0].response;
904
+ };
905
+ revokeBotToken = async (botTokenGuid) => {
906
+ const response = await this.sendRequest({
907
+ type: {
908
+ oneofKind: "revokeBotToken",
909
+ revokeBotToken: {
910
+ botTokenGuid
911
+ },
912
+ },
913
+ });
914
+ if (response.length <= 0) {
915
+ throw new Error("Server timed out");
916
+ }
917
+ return response[0].response;
918
+ };
856
919
  createTournament = async (tournament) => {
857
920
  const response = await this.sendRequest({
858
921
  type: {
package/package.json CHANGED
@@ -1,13 +1,19 @@
1
1
  {
2
2
  "name": "moons-ta-client",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "type": "module",
5
5
  "main": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
- "node": "./dist/index.js",
10
- "default": "./dist/index.esm.js"
9
+ "node": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "default": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.esm.js"
16
+ }
11
17
  }
12
18
  },
13
19
  "scripts": {