@duque.edits/sdk 0.0.4 → 0.0.6

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.
Files changed (155) hide show
  1. package/{v1/index.ts → dist/index.d.ts} +27 -30
  2. package/dist/index.js +43 -0
  3. package/dist/managers/bet/GuildBetManager.d.ts +32 -0
  4. package/dist/managers/bet/GuildBetManager.js +107 -0
  5. package/dist/managers/betuser/GuildBetUserManager.d.ts +30 -0
  6. package/dist/managers/betuser/GuildBetUserManager.js +94 -0
  7. package/dist/managers/channel/ChannelManager.d.ts +39 -0
  8. package/dist/managers/channel/ChannelManager.js +147 -0
  9. package/dist/managers/groupedchannel/GroupedChannelManager.d.ts +34 -0
  10. package/dist/managers/groupedchannel/GroupedChannelManager.js +92 -0
  11. package/dist/managers/guild/GuildManager.d.ts +24 -0
  12. package/dist/managers/guild/GuildManager.js +75 -0
  13. package/dist/managers/match/GuildMatchManager.d.ts +32 -0
  14. package/dist/managers/match/GuildMatchManager.js +103 -0
  15. package/dist/managers/mediator/GuildMediatorManager.d.ts +32 -0
  16. package/dist/managers/mediator/GuildMediatorManager.js +97 -0
  17. package/dist/managers/messages/MessagesManager.d.ts +32 -0
  18. package/dist/managers/messages/MessagesManager.js +82 -0
  19. package/dist/managers/permission/GuildPermissionManager.d.ts +26 -0
  20. package/dist/managers/permission/GuildPermissionManager.js +70 -0
  21. package/dist/managers/product/GuildProductManager.d.ts +32 -0
  22. package/dist/managers/product/GuildProductManager.js +102 -0
  23. package/dist/managers/ticket/GuildTicketManager.d.ts +32 -0
  24. package/dist/managers/ticket/GuildTicketManager.js +99 -0
  25. package/dist/managers/user/GuildUserManager.d.ts +32 -0
  26. package/dist/managers/user/GuildUserManager.js +106 -0
  27. package/dist/rest/APIEndpoints.d.ts +11 -0
  28. package/dist/rest/APIEndpoints.js +12 -0
  29. package/dist/rest/REST.d.ts +51 -0
  30. package/dist/rest/REST.js +96 -0
  31. package/dist/rest/Routes.d.ts +84 -0
  32. package/dist/rest/Routes.js +89 -0
  33. package/dist/structures/Collection.d.ts +17 -0
  34. package/dist/structures/Collection.js +87 -0
  35. package/dist/structures/bet/GuildBet.d.ts +86 -0
  36. package/dist/structures/bet/GuildBet.js +276 -0
  37. package/dist/structures/betuser/GuildBetUser.d.ts +82 -0
  38. package/dist/structures/betuser/GuildBetUser.js +194 -0
  39. package/dist/structures/channel/Channel.d.ts +31 -0
  40. package/dist/structures/channel/Channel.js +57 -0
  41. package/dist/structures/groupedchannel/GroupedChannel.d.ts +34 -0
  42. package/dist/structures/groupedchannel/GroupedChannel.js +121 -0
  43. package/dist/structures/guild/Guild.d.ts +90 -0
  44. package/dist/structures/guild/Guild.js +254 -0
  45. package/dist/structures/match/GuildMatch.d.ts +84 -0
  46. package/dist/structures/match/GuildMatch.js +327 -0
  47. package/dist/structures/mediator/GuildMediator.d.ts +41 -0
  48. package/dist/structures/mediator/GuildMediator.js +131 -0
  49. package/dist/structures/product/GuildProduct.d.ts +52 -0
  50. package/dist/structures/product/GuildProduct.js +175 -0
  51. package/dist/structures/shop/GuildShop.d.ts +34 -0
  52. package/dist/structures/shop/GuildShop.js +80 -0
  53. package/dist/structures/ticket/GuildTicket.d.ts +51 -0
  54. package/dist/structures/ticket/GuildTicket.js +170 -0
  55. package/dist/structures/user/GuildUser.d.ts +82 -0
  56. package/dist/structures/user/GuildUser.js +208 -0
  57. package/dist/types/api/APIBaseChannel.d.ts +10 -0
  58. package/dist/types/api/APIBaseChannel.js +2 -0
  59. package/dist/types/api/APIBetChannel.d.ts +10 -0
  60. package/dist/types/api/APIBetChannel.js +2 -0
  61. package/dist/types/api/APIBetMessage.d.ts +10 -0
  62. package/dist/types/api/APIBetMessage.js +2 -0
  63. package/dist/types/api/APIGuild.d.ts +93 -0
  64. package/dist/types/api/APIGuild.js +2 -0
  65. package/dist/types/api/APIGuildBet.d.ts +48 -0
  66. package/dist/types/api/APIGuildBet.js +2 -0
  67. package/dist/types/api/APIGuildBetUser.d.ts +32 -0
  68. package/dist/types/api/APIGuildBetUser.js +2 -0
  69. package/dist/types/api/APIGuildChannel.d.ts +10 -0
  70. package/dist/types/api/APIGuildChannel.js +2 -0
  71. package/dist/types/api/APIGuildEmoji.d.ts +12 -0
  72. package/dist/types/api/APIGuildEmoji.js +2 -0
  73. package/dist/types/api/APIGuildGroupedChannel.d.ts +10 -0
  74. package/dist/types/api/APIGuildGroupedChannel.js +2 -0
  75. package/dist/types/api/APIGuildMatch.d.ts +46 -0
  76. package/dist/types/api/APIGuildMatch.js +2 -0
  77. package/dist/types/api/APIGuildMediator.d.ts +13 -0
  78. package/dist/types/api/APIGuildMediator.js +3 -0
  79. package/dist/types/api/APIGuildMessage.d.ts +10 -0
  80. package/dist/types/api/APIGuildMessage.js +2 -0
  81. package/dist/types/api/APIGuildPermissions.d.ts +6 -0
  82. package/dist/types/api/APIGuildPermissions.js +2 -0
  83. package/dist/types/api/APIGuildRole.d.ts +10 -0
  84. package/dist/types/api/APIGuildRole.js +2 -0
  85. package/dist/types/api/APIGuildShop.d.ts +11 -0
  86. package/dist/types/api/APIGuildShop.js +2 -0
  87. package/dist/types/api/APIGuildTicket.d.ts +25 -0
  88. package/dist/types/api/APIGuildTicket.js +3 -0
  89. package/dist/types/api/APIGuildUser.d.ts +31 -0
  90. package/dist/types/api/APIGuildUser.js +2 -0
  91. package/dist/types/api/APIMessage.d.ts +12 -0
  92. package/dist/types/api/APIMessage.js +2 -0
  93. package/dist/types/api/APIPlayer.d.ts +10 -0
  94. package/dist/types/api/APIPlayer.js +2 -0
  95. package/dist/types/api/APIProduct.d.ts +19 -0
  96. package/dist/types/api/APIProduct.js +3 -0
  97. package/dist/types/api/index.d.ts +130 -0
  98. package/dist/types/api/index.js +35 -0
  99. package/{v1/types/index.ts → dist/types/index.d.ts} +21 -24
  100. package/dist/types/index.js +37 -0
  101. package/dist/utils/Assertion.d.ts +32 -0
  102. package/dist/utils/Assertion.js +60 -0
  103. package/package.json +15 -1
  104. package/.gitattributes +0 -2
  105. package/tests/index.ts +0 -86
  106. package/tsconfig.json +0 -15
  107. package/v1/managers/bet/GuildBetManager.ts +0 -117
  108. package/v1/managers/betuser/GuildBetUserManager.ts +0 -103
  109. package/v1/managers/channel/ChannelManager.ts +0 -168
  110. package/v1/managers/groupedchannel/GroupedChannelManager.ts +0 -117
  111. package/v1/managers/guild/GuildManager.ts +0 -84
  112. package/v1/managers/match/GuildMatchManager.ts +0 -115
  113. package/v1/managers/mediator/GuildMediatorManager.ts +0 -111
  114. package/v1/managers/messages/MessagesManager.ts +0 -95
  115. package/v1/managers/permission/GuildPermissionManager.ts +0 -88
  116. package/v1/managers/product/GuildProductManager.ts +0 -115
  117. package/v1/managers/ticket/GuildTicketManager.ts +0 -112
  118. package/v1/managers/user/GuildUserManager.ts +0 -116
  119. package/v1/rest/APIEndpoints.ts +0 -11
  120. package/v1/rest/REST.ts +0 -126
  121. package/v1/rest/Routes.ts +0 -143
  122. package/v1/structures/Collection.ts +0 -85
  123. package/v1/structures/bet/GuildBet.ts +0 -332
  124. package/v1/structures/betuser/GuildBetUser.ts +0 -247
  125. package/v1/structures/channel/Channel.ts +0 -78
  126. package/v1/structures/groupedchannel/GroupedChannel.ts +0 -165
  127. package/v1/structures/guild/Guild.ts +0 -302
  128. package/v1/structures/match/GuildMatch.ts +0 -385
  129. package/v1/structures/mediator/GuildMediator.ts +0 -175
  130. package/v1/structures/product/GuildProduct.ts +0 -217
  131. package/v1/structures/shop/GuildShop.ts +0 -98
  132. package/v1/structures/ticket/GuildTicket.ts +0 -227
  133. package/v1/structures/user/GuildUser.ts +0 -248
  134. package/v1/types/api/APIBaseChannel.ts +0 -13
  135. package/v1/types/api/APIBetChannel.ts +0 -13
  136. package/v1/types/api/APIBetMessage.ts +0 -13
  137. package/v1/types/api/APIGuild.ts +0 -123
  138. package/v1/types/api/APIGuildBet.ts +0 -69
  139. package/v1/types/api/APIGuildBetUser.ts +0 -46
  140. package/v1/types/api/APIGuildChannel.ts +0 -13
  141. package/v1/types/api/APIGuildEmoji.ts +0 -16
  142. package/v1/types/api/APIGuildGroupedChannel.ts +0 -13
  143. package/v1/types/api/APIGuildMatch.ts +0 -67
  144. package/v1/types/api/APIGuildMediator.ts +0 -18
  145. package/v1/types/api/APIGuildMessage.ts +0 -13
  146. package/v1/types/api/APIGuildPermissions.ts +0 -7
  147. package/v1/types/api/APIGuildRole.ts +0 -13
  148. package/v1/types/api/APIGuildShop.ts +0 -15
  149. package/v1/types/api/APIGuildTicket.ts +0 -36
  150. package/v1/types/api/APIGuildUser.ts +0 -45
  151. package/v1/types/api/APIMessage.ts +0 -16
  152. package/v1/types/api/APIPlayer.ts +0 -13
  153. package/v1/types/api/APIProduct.ts +0 -27
  154. package/v1/types/api/index.ts +0 -180
  155. package/v1/utils/Assertion.ts +0 -56
@@ -1,30 +1,27 @@
1
- export * from "./managers/bet/GuildBetManager";
2
- export * from "./managers/betuser/GuildBetUserManager";
3
- export * from "./managers/channel/ChannelManager";
4
- export * from "./managers/groupedchannel/GroupedChannelManager";
5
- export * from "./managers/guild/GuildManager";
6
- export * from "./managers/match/GuildMatchManager";
7
- export * from "./managers/mediator/GuildMediatorManager";
8
- export * from "./managers/messages/MessagesManager";
9
- export * from "./managers/permission/GuildPermissionManager";
10
- export * from "./managers/product/GuildProductManager";
11
- export * from "./managers/ticket/GuildTicketManager";
12
- export * from "./managers/user/GuildUserManager";
13
-
14
- export * from "./structures/bet/GuildBet";
15
- export * from "./structures/betuser/GuildBetUser";
16
- export * from "./structures/channel/Channel";
17
- export * from "./structures/groupedchannel/GroupedChannel";
18
- export * from "./structures/guild/Guild";
19
- export * from "./structures/match/GuildMatch";
20
- export * from "./structures/mediator/GuildMediator";
21
- export * from "./structures/product/GuildProduct";
22
- export * from "./structures/shop/GuildShop";
23
- export * from "./structures/ticket/GuildTicket";
24
- export * from "./structures/user/GuildUser";
25
- export * from "./structures/Collection";
26
-
27
- export * from "./rest/REST";
28
- export * from "./rest/Routes";
29
-
30
- export * from "./types/index";
1
+ export * from "./managers/bet/GuildBetManager";
2
+ export * from "./managers/betuser/GuildBetUserManager";
3
+ export * from "./managers/channel/ChannelManager";
4
+ export * from "./managers/groupedchannel/GroupedChannelManager";
5
+ export * from "./managers/guild/GuildManager";
6
+ export * from "./managers/match/GuildMatchManager";
7
+ export * from "./managers/mediator/GuildMediatorManager";
8
+ export * from "./managers/messages/MessagesManager";
9
+ export * from "./managers/permission/GuildPermissionManager";
10
+ export * from "./managers/product/GuildProductManager";
11
+ export * from "./managers/ticket/GuildTicketManager";
12
+ export * from "./managers/user/GuildUserManager";
13
+ export * from "./structures/bet/GuildBet";
14
+ export * from "./structures/betuser/GuildBetUser";
15
+ export * from "./structures/channel/Channel";
16
+ export * from "./structures/groupedchannel/GroupedChannel";
17
+ export * from "./structures/guild/Guild";
18
+ export * from "./structures/match/GuildMatch";
19
+ export * from "./structures/mediator/GuildMediator";
20
+ export * from "./structures/product/GuildProduct";
21
+ export * from "./structures/shop/GuildShop";
22
+ export * from "./structures/ticket/GuildTicket";
23
+ export * from "./structures/user/GuildUser";
24
+ export * from "./structures/Collection";
25
+ export * from "./rest/REST";
26
+ export * from "./rest/Routes";
27
+ export * from "./types/index";
package/dist/index.js ADDED
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./managers/bet/GuildBetManager"), exports);
18
+ __exportStar(require("./managers/betuser/GuildBetUserManager"), exports);
19
+ __exportStar(require("./managers/channel/ChannelManager"), exports);
20
+ __exportStar(require("./managers/groupedchannel/GroupedChannelManager"), exports);
21
+ __exportStar(require("./managers/guild/GuildManager"), exports);
22
+ __exportStar(require("./managers/match/GuildMatchManager"), exports);
23
+ __exportStar(require("./managers/mediator/GuildMediatorManager"), exports);
24
+ __exportStar(require("./managers/messages/MessagesManager"), exports);
25
+ __exportStar(require("./managers/permission/GuildPermissionManager"), exports);
26
+ __exportStar(require("./managers/product/GuildProductManager"), exports);
27
+ __exportStar(require("./managers/ticket/GuildTicketManager"), exports);
28
+ __exportStar(require("./managers/user/GuildUserManager"), exports);
29
+ __exportStar(require("./structures/bet/GuildBet"), exports);
30
+ __exportStar(require("./structures/betuser/GuildBetUser"), exports);
31
+ __exportStar(require("./structures/channel/Channel"), exports);
32
+ __exportStar(require("./structures/groupedchannel/GroupedChannel"), exports);
33
+ __exportStar(require("./structures/guild/Guild"), exports);
34
+ __exportStar(require("./structures/match/GuildMatch"), exports);
35
+ __exportStar(require("./structures/mediator/GuildMediator"), exports);
36
+ __exportStar(require("./structures/product/GuildProduct"), exports);
37
+ __exportStar(require("./structures/shop/GuildShop"), exports);
38
+ __exportStar(require("./structures/ticket/GuildTicket"), exports);
39
+ __exportStar(require("./structures/user/GuildUser"), exports);
40
+ __exportStar(require("./structures/Collection"), exports);
41
+ __exportStar(require("./rest/REST"), exports);
42
+ __exportStar(require("./rest/Routes"), exports);
43
+ __exportStar(require("./types/index"), exports);
@@ -0,0 +1,32 @@
1
+ import { REST } from "../../rest/REST";
2
+ import { GuildBet } from "../../structures/bet/GuildBet";
3
+ import { Collection } from "../../structures/Collection";
4
+ import { Guild } from "../../structures/guild/Guild";
5
+ import { Optional } from "../../types/api";
6
+ import { APIGuildBet } from "../../types/api/APIGuildBet";
7
+ export declare class GuildBetManager {
8
+ /** A cache of users */
9
+ cache: Collection<string, GuildBet>;
10
+ /** The rest client */
11
+ rest: REST;
12
+ /** GuildBet bet guild */
13
+ guild: Guild;
14
+ /**
15
+ * Manage users with the given client
16
+ * @param users An array of users
17
+ * @param rest The rest client
18
+ */
19
+ constructor(guild: Guild, rest: REST);
20
+ create(payload: Optional<APIGuildBet>): Promise<GuildBet>;
21
+ /**
22
+ * Fetch a bet
23
+ * @param id Id of the bet to fetch
24
+ * @returns APIBetUser
25
+ */
26
+ fetch(id: string): Promise<GuildBet>;
27
+ fetchAll(): Promise<Collection<string, GuildBet>>;
28
+ set(data: APIGuildBet): GuildBet;
29
+ setAll(data: APIGuildBet[]): Collection<string, GuildBet>;
30
+ delete(id: string): Promise<Collection<string, GuildBet>>;
31
+ deleteAll(): Promise<boolean>;
32
+ }
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GuildBetManager = void 0;
4
+ const Routes_1 = require("../../rest/Routes");
5
+ const GuildBet_1 = require("../../structures/bet/GuildBet");
6
+ const Collection_1 = require("../../structures/Collection");
7
+ const Assertion_1 = require("../../utils/Assertion");
8
+ class GuildBetManager {
9
+ /** A cache of users */
10
+ cache;
11
+ /** The rest client */
12
+ rest;
13
+ /** GuildBet bet guild */
14
+ guild;
15
+ /**
16
+ * Manage users with the given client
17
+ * @param users An array of users
18
+ * @param rest The rest client
19
+ */
20
+ constructor(guild, rest) {
21
+ this.guild = guild;
22
+ this.rest = rest;
23
+ this.cache = new Collection_1.Collection("bets");
24
+ }
25
+ async create(payload) {
26
+ Assertion_1.Assertion.assertObject(payload);
27
+ const route = Routes_1.Routes.guilds.bets.create(this.guild.id);
28
+ const response = await this.rest.request({
29
+ method: "POST",
30
+ url: route,
31
+ });
32
+ const bet = this.set(response);
33
+ return bet;
34
+ }
35
+ /**
36
+ * Fetch a bet
37
+ * @param id Id of the bet to fetch
38
+ * @returns APIBetUser
39
+ */
40
+ async fetch(id) {
41
+ const route = Routes_1.Routes.guilds.bets.get(this.guild.id, id);
42
+ const response = await this.rest.request({
43
+ method: "get",
44
+ url: route,
45
+ });
46
+ const bet = new GuildBet_1.GuildBet(response, this.guild, this, this.rest);
47
+ this.cache.set(bet._id, bet);
48
+ this.rest.bets.set(bet._id, bet);
49
+ return bet;
50
+ }
51
+ async fetchAll() {
52
+ const route = Routes_1.Routes.guilds.bets.getAll(this.guild.id);
53
+ const response = await this.rest.request({
54
+ method: "get",
55
+ url: route,
56
+ });
57
+ if (Array.isArray(response) && response.length === 0) {
58
+ this.cache.clear();
59
+ return this.cache;
60
+ }
61
+ for (let betData of response) {
62
+ const bet = new GuildBet_1.GuildBet(betData, this.guild, this, this.rest);
63
+ this.cache.set(bet._id, bet);
64
+ }
65
+ return this.cache;
66
+ }
67
+ set(data) {
68
+ if (!data._id)
69
+ return;
70
+ const bet = new GuildBet_1.GuildBet(data, this.guild, this, this.rest);
71
+ this.cache.set(bet._id, bet);
72
+ this.rest.bets.set(bet._id, bet);
73
+ return bet;
74
+ }
75
+ setAll(data) {
76
+ if (!data)
77
+ return this.cache;
78
+ for (let bet of data)
79
+ this.set(bet);
80
+ return this.cache;
81
+ }
82
+ ;
83
+ async delete(id) {
84
+ Assertion_1.Assertion.assertString(id);
85
+ const route = Routes_1.Routes.guilds.bets.delete(id, this.guild.id);
86
+ const bet = this.cache.get(id);
87
+ this.rest.emit("betDelete", bet);
88
+ await this.rest.request({
89
+ method: "DELETE",
90
+ url: route,
91
+ });
92
+ this.cache.delete(id);
93
+ return this.cache;
94
+ }
95
+ async deleteAll() {
96
+ const route = Routes_1.Routes.guilds.bets.deleteAll(this.guild.id);
97
+ this.rest.emit("betsDelete", this.cache);
98
+ const value = await this.rest.request({
99
+ method: "DELETE",
100
+ url: route,
101
+ });
102
+ this.cache.clear();
103
+ return value;
104
+ }
105
+ }
106
+ exports.GuildBetManager = GuildBetManager;
107
+ ;
@@ -0,0 +1,30 @@
1
+ import { REST } from "../../rest/REST";
2
+ import { GuildBetUser } from "../../structures/betuser/GuildBetUser";
3
+ import { Collection } from "../../structures/Collection";
4
+ import { Guild } from "../../structures/guild/Guild";
5
+ import { APIGuildBetUser } from "../../types/api/APIGuildBetUser";
6
+ export declare class GuildBetUserManager {
7
+ /** A cache of users */
8
+ cache: Collection<string, GuildBetUser>;
9
+ /** The rest client */
10
+ rest: REST;
11
+ /** Bet user guild */
12
+ guild: Guild;
13
+ /**
14
+ * Manage users with the given client
15
+ * @param users An array of users
16
+ * @param rest The rest client
17
+ */
18
+ constructor(guild: Guild, rest: REST);
19
+ set(data: APIGuildBetUser): Collection<string, GuildBetUser>;
20
+ setAll(data: APIGuildBetUser[]): Collection<string, GuildBetUser>;
21
+ /**
22
+ * Fetch a user
23
+ * @param id Id of the user to fetch
24
+ * @returns GuildBetUser
25
+ */
26
+ fetch(id: string, name: string): Promise<GuildBetUser>;
27
+ fetchAll(): Promise<Collection<string, GuildBetUser>>;
28
+ delete(id: string): Promise<Collection<string, GuildBetUser>>;
29
+ deleteAll(): Promise<boolean>;
30
+ }
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GuildBetUserManager = void 0;
4
+ const Routes_1 = require("../../rest/Routes");
5
+ const GuildBetUser_1 = require("../../structures/betuser/GuildBetUser");
6
+ const Collection_1 = require("../../structures/Collection");
7
+ const Assertion_1 = require("../../utils/Assertion");
8
+ class GuildBetUserManager {
9
+ /** A cache of users */
10
+ cache;
11
+ /** The rest client */
12
+ rest;
13
+ /** Bet user guild */
14
+ guild;
15
+ /**
16
+ * Manage users with the given client
17
+ * @param users An array of users
18
+ * @param rest The rest client
19
+ */
20
+ constructor(guild, rest) {
21
+ this.guild = guild;
22
+ this.rest = rest;
23
+ this.cache = new Collection_1.Collection("betUsers");
24
+ }
25
+ set(data) {
26
+ if (!data.id)
27
+ return;
28
+ const user = new GuildBetUser_1.GuildBetUser(data, this, this.rest);
29
+ this.rest.betUsers.set(user.id, user);
30
+ return this.cache.set(user.id, user);
31
+ }
32
+ setAll(data) {
33
+ if (!data)
34
+ return this.cache;
35
+ for (let user of data)
36
+ this.set(user);
37
+ return this.cache;
38
+ }
39
+ /**
40
+ * Fetch a user
41
+ * @param id Id of the user to fetch
42
+ * @returns GuildBetUser
43
+ */
44
+ async fetch(id, name) {
45
+ const route = Routes_1.Routes.guilds.betUsers.get(this.guild.id, id);
46
+ const response = await this.rest.request({
47
+ method: "get",
48
+ url: route,
49
+ payload: { name },
50
+ });
51
+ if (!response)
52
+ return this.cache.get(id);
53
+ const user = new GuildBetUser_1.GuildBetUser(response, this, this.rest);
54
+ this.cache.set(user?.id, user);
55
+ this.rest.betUsers.set(user?.id, user);
56
+ return user;
57
+ }
58
+ async fetchAll() {
59
+ const route = Routes_1.Routes.guilds.betUsers.getAll(this.guild.id);
60
+ const response = await this.rest.request({
61
+ method: "get",
62
+ url: route,
63
+ });
64
+ if (Array.isArray(response) && response.length === 0) {
65
+ this.cache.clear();
66
+ return this.cache;
67
+ }
68
+ this.setAll(response);
69
+ return this.cache;
70
+ }
71
+ async delete(id) {
72
+ Assertion_1.Assertion.assertString(id);
73
+ const route = Routes_1.Routes.guilds.betUsers.delete(id, this.guild.id);
74
+ const betUser = this.cache.get(id);
75
+ this.rest.emit("betDelete", betUser);
76
+ await this.rest.request({
77
+ method: "DELETE",
78
+ url: route,
79
+ });
80
+ this.cache.delete(id);
81
+ return this.cache;
82
+ }
83
+ async deleteAll() {
84
+ const route = Routes_1.Routes.guilds.betUsers.deleteAll(this.guild.id);
85
+ this.rest.emit("betsDelete", this.cache);
86
+ const value = await this.rest.request({
87
+ method: "DELETE",
88
+ url: route,
89
+ });
90
+ this.cache.clear();
91
+ return value;
92
+ }
93
+ }
94
+ exports.GuildBetUserManager = GuildBetUserManager;
@@ -0,0 +1,39 @@
1
+ import { REST } from "../../rest/REST";
2
+ import { GuildBet } from "../../structures/bet/GuildBet";
3
+ import { Channel } from "../../structures/channel/Channel";
4
+ import { Collection } from "../../structures/Collection";
5
+ import { Guild } from "../../structures/guild/Guild";
6
+ import { GuildMatch } from "../../structures/match/GuildMatch";
7
+ import { Optional } from "../../types/api";
8
+ import { APIBaseChannel } from "../../types/api/APIBaseChannel";
9
+ type Channels = Optional<APIBaseChannel>;
10
+ export declare class ChannelManager<Structure extends GuildBet | GuildMatch> {
11
+ /** A cache of bet channels */
12
+ cache: Collection<string, Channel<Structure>>;
13
+ /** The rest client */
14
+ rest: REST;
15
+ /** GuildBet user guild */
16
+ guild: Guild;
17
+ /** The bet */
18
+ structure: Structure;
19
+ /** Base Url */
20
+ baseUrl: string;
21
+ /**
22
+ * Manage channels of a bet
23
+ * @param guild The guild at hand
24
+ * @param bet The bet at hand
25
+ * @param rest The rest client
26
+ */
27
+ constructor(guild: Guild, structure: Structure, rest: REST);
28
+ create(id: string, type: string): Promise<Channel<Structure>>;
29
+ createMany(...channels: Channels[]): Promise<Collection<string, Channel<Structure>>>;
30
+ deleteMany(...channels: Optional<APIBaseChannel>[]): Promise<Collection<string, Channel<Structure>>>;
31
+ setAll(data: APIBaseChannel[]): Collection<string, Channel<Structure>>;
32
+ set(data: APIBaseChannel): Channel<Structure>;
33
+ update(type: string, payload: Optional<APIBaseChannel>): Promise<Channel<Structure>>;
34
+ fetch(type: string): Promise<Channel<Structure>>;
35
+ fetchAll(): Promise<Collection<string, Channel<Structure>>>;
36
+ delete(type: string): Promise<Collection<string, Channel<Structure>>>;
37
+ deleteAll(): Promise<boolean>;
38
+ }
39
+ export {};
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChannelManager = void 0;
4
+ const Routes_1 = require("../../rest/Routes");
5
+ const Channel_1 = require("../../structures/channel/Channel");
6
+ const Collection_1 = require("../../structures/Collection");
7
+ const Assertion_1 = require("../../utils/Assertion");
8
+ class ChannelManager {
9
+ /** A cache of bet channels */
10
+ cache;
11
+ /** The rest client */
12
+ rest;
13
+ /** GuildBet user guild */
14
+ guild;
15
+ /** The bet */
16
+ structure;
17
+ /** Base Url */
18
+ baseUrl;
19
+ /**
20
+ * Manage channels of a bet
21
+ * @param guild The guild at hand
22
+ * @param bet The bet at hand
23
+ * @param rest The rest client
24
+ */
25
+ constructor(guild, structure, rest) {
26
+ this.structure = structure;
27
+ this.rest = rest;
28
+ this.guild = guild;
29
+ this.cache = new Collection_1.Collection("channels");
30
+ this.baseUrl = Routes_1.Routes.guilds[structure.key].resource(guild.id, structure._id, "channels");
31
+ }
32
+ async create(id, type) {
33
+ Assertion_1.Assertion.assertString(id);
34
+ Assertion_1.Assertion.assertString(type);
35
+ const route = this.baseUrl;
36
+ const payload = { id, type };
37
+ const response = await this.rest.request({
38
+ method: "POST",
39
+ url: route,
40
+ payload,
41
+ });
42
+ const channel = this.set(response);
43
+ this.rest.emit("channelCreate", channel);
44
+ return channel;
45
+ }
46
+ async createMany(...channels) {
47
+ Assertion_1.Assertion.assertArray(channels);
48
+ const route = Routes_1.Routes.fields(this.baseUrl, "bulk");
49
+ const payload = { channels };
50
+ const response = await this.rest.request({
51
+ method: "POST",
52
+ url: route,
53
+ payload,
54
+ });
55
+ this.rest.emit("channelBulkCreate", response);
56
+ return this.setAll(response);
57
+ }
58
+ async deleteMany(...channels) {
59
+ Assertion_1.Assertion.assertArray(channels);
60
+ const route = Routes_1.Routes.fields(this.baseUrl, "bulk");
61
+ const payload = { channels };
62
+ const response = await this.rest.request({
63
+ method: "DELETE",
64
+ url: route,
65
+ payload,
66
+ });
67
+ const channel = this.setAll(response);
68
+ this.rest.emit("channelBulkDelete", channel);
69
+ return channel;
70
+ }
71
+ setAll(data) {
72
+ if (!data)
73
+ return this.cache;
74
+ for (let channelData of data)
75
+ this.set(channelData);
76
+ return this.cache;
77
+ }
78
+ set(data) {
79
+ if (!data.type)
80
+ return;
81
+ const channel = new Channel_1.Channel({
82
+ baseUrl: Routes_1.Routes.guilds[this.structure.key].resource(this.guild.id, this.structure._id, "channels"),
83
+ data: data,
84
+ guild: this.guild,
85
+ manager: this,
86
+ }, this.rest);
87
+ this.cache.set(data.type, channel);
88
+ return channel;
89
+ }
90
+ async update(type, payload) {
91
+ Assertion_1.Assertion.assertString(type);
92
+ Assertion_1.Assertion.assertObject(payload);
93
+ const route = Routes_1.Routes.fields(this.baseUrl, type);
94
+ const response = await this.rest.request({
95
+ method: "PATCH",
96
+ url: route,
97
+ payload,
98
+ });
99
+ const channel = this.set(response);
100
+ this.rest.emit("betUpdate", this.structure, this.structure);
101
+ return channel;
102
+ }
103
+ async fetch(type) {
104
+ Assertion_1.Assertion.assertString(type);
105
+ const route = Routes_1.Routes.fields(this.baseUrl, type);
106
+ const response = await this.rest.request({
107
+ method: "GET",
108
+ url: route,
109
+ });
110
+ const channel = this.set(response);
111
+ this.cache.set(channel.type, channel);
112
+ return channel;
113
+ }
114
+ async fetchAll() {
115
+ const response = await this.rest.request({
116
+ method: "GET",
117
+ url: this.baseUrl,
118
+ });
119
+ if (Array.isArray(response) && response.length === 0) {
120
+ this.cache.clear();
121
+ return this.cache;
122
+ }
123
+ for (let channelData of response)
124
+ this.set(channelData);
125
+ return this.cache;
126
+ }
127
+ async delete(type) {
128
+ Assertion_1.Assertion.assertString(type);
129
+ const route = this.baseUrl;
130
+ const response = await this.rest.request({
131
+ method: "DELETE",
132
+ url: Routes_1.Routes.fields(route, type),
133
+ });
134
+ this.cache.delete(type);
135
+ return this.cache;
136
+ }
137
+ async deleteAll() {
138
+ const route = this.baseUrl;
139
+ const value = await this.rest.request({
140
+ method: "DELETE",
141
+ url: route,
142
+ });
143
+ this.cache.clear();
144
+ return value;
145
+ }
146
+ }
147
+ exports.ChannelManager = ChannelManager;
@@ -0,0 +1,34 @@
1
+ import { REST } from "../../rest/REST";
2
+ import { GroupedChannel } from "../../structures/groupedchannel/GroupedChannel";
3
+ import { Collection } from "../../structures/Collection";
4
+ import { Guild } from "../../structures/guild/Guild";
5
+ import { Optional } from "../../types/api";
6
+ import { APIGuildGroupedChannel } from "../../types/api/APIGuildGroupedChannel";
7
+ export declare class GroupedChannelManager {
8
+ /** A cache of channels */
9
+ cache: Collection<string, GroupedChannel>;
10
+ /** Key */
11
+ key: string;
12
+ baseUrl: string;
13
+ /** The rest client */
14
+ rest: REST;
15
+ /** GroupedChannel groupedChannel guild */
16
+ guild: Guild;
17
+ /**
18
+ * Manage channels with the given client
19
+ * @param channels An array of channels
20
+ * @param rest The rest client
21
+ */
22
+ constructor(guild: Guild, key: string, rest: REST);
23
+ delete(type: string): Promise<boolean>;
24
+ create(payload: Optional<APIGuildGroupedChannel>): Promise<GroupedChannel>;
25
+ /**
26
+ * Fetch a groupedChannel
27
+ * @param id Id of the groupedChannel to fetch
28
+ * @returns APIgroupedChannelUser
29
+ */
30
+ fetch(type: string): Promise<GroupedChannel>;
31
+ fetchAll(): Promise<Collection<string, GroupedChannel>>;
32
+ setAll(data: APIGuildGroupedChannel[]): Collection<string, GroupedChannel>;
33
+ set(data: APIGuildGroupedChannel): GroupedChannel;
34
+ }