@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,165 +0,0 @@
1
- import { REST } from "../../rest/REST";
2
- import { Routes } from "../../rest/Routes";
3
- import { Guild } from "../guild/Guild";
4
- import { APIGuildGroupedChannel } from "../../types/api/APIGuildGroupedChannel";
5
- import { Confirm, Optional } from "../../types/api";
6
- import { Assertion } from "../../utils/Assertion";
7
- import { GroupedChannelManager } from "../../managers/groupedchannel/GroupedChannelManager";
8
-
9
- export class GroupedChannel {
10
- type: string;
11
- ids: string[];
12
-
13
- createdAt: Date;
14
- updatedAt: Date;
15
- manager: GroupedChannelManager;
16
-
17
- /** The given guild */
18
- readonly guild: Guild;
19
-
20
- /** The rest client */
21
- readonly rest: REST;
22
-
23
- /**
24
- * GroupedChannel channel
25
- * @param data The channel's data
26
- * @param guild The guild
27
- * @param rest The rest client
28
- */
29
-
30
- constructor(
31
- data: APIGuildGroupedChannel,
32
- guild: Guild,
33
- manager: GroupedChannelManager,
34
- rest: REST
35
- ) {
36
- this.ids = data?.ids;
37
- this.type = data?.type;
38
-
39
- this.manager = manager;
40
-
41
- this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
42
- this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
43
-
44
- this.guild = guild;
45
- this.rest = rest;
46
- }
47
-
48
- /**
49
- * Fetches the channel
50
- * @returns New Instance of the channel
51
- */
52
- async fetch(): Promise<GroupedChannel> {
53
- const route = Routes.fields(this.manager.baseUrl, this.type);
54
- const response = await this.rest.request<APIGuildGroupedChannel, {}>({
55
- method: "get",
56
- url: route,
57
- });
58
-
59
- const channel = new GroupedChannel(
60
- response,
61
- this.guild,
62
- this.manager,
63
- this.rest
64
- );
65
-
66
- this.manager.cache.set(channel.type, channel);
67
- return channel;
68
- }
69
- async setIds(ids: string[]) {
70
- Assertion.assertArray(ids);
71
-
72
- const payload = { ids };
73
- const route = Routes.fields(this.manager.baseUrl, this.type, "ids");
74
- const response = await this.rest.request<APIGuildGroupedChannel, {}>({
75
- method: "PUT",
76
- url: route,
77
- payload,
78
- });
79
-
80
- this.ids = ids;
81
- this.updatedAt = new Date();
82
- this.rest.emit("groupedChannelUpdate", this,
83
- new GroupedChannel(response, this.guild, this.manager, this.rest));
84
- return this;
85
- }
86
- async addId(id: string) {
87
- Assertion.assertString(id);
88
-
89
- const payload = { id };
90
- const route = Routes.fields(this.manager.baseUrl, this.type, "ids");
91
- const response = await this.rest.request<APIGuildGroupedChannel, {}>({
92
- method: "POST",
93
- url: route,
94
- payload,
95
- });
96
- this.ids = response.ids;
97
-
98
- this.updatedAt = new Date();
99
-
100
- this.manager.set(response);
101
- this.rest.emit("groupedChannelUpdate", this,
102
- new GroupedChannel(response, this.guild, this.manager, this.rest));
103
- return this;
104
- }
105
-
106
- async removeId(id: string) {
107
- Assertion.assertString(id);
108
-
109
- const payload = { id };
110
- const route = Routes.fields(this.manager.baseUrl, this.type, "ids", id);
111
- const response = await this.rest.request<APIGuildGroupedChannel, {}>({
112
- method: "DELETE",
113
- url: route,
114
- payload,
115
- });
116
-
117
- this.ids = response.ids;
118
- this.updatedAt = new Date();
119
- this.rest.emit("groupedChannelUpdate", this,
120
- new GroupedChannel(response, this.guild, this.manager, this.rest));
121
- return this;
122
- }
123
- async update(
124
- data: Optional<APIGuildGroupedChannel>
125
- ): Promise<GroupedChannel> {
126
- const route = Routes.fields(this.manager.baseUrl, this.type);
127
- const payload = data;
128
-
129
- const response = await this.rest.request<
130
- APIGuildGroupedChannel,
131
- typeof payload
132
- >({
133
- method: "patch",
134
- url: route,
135
- payload,
136
- });
137
- this.rest.emit(
138
- "groupedChannelUpdate",
139
- this,
140
- new GroupedChannel(response, this.guild, this.manager, this.rest)
141
- );
142
- for (const k in response) {
143
- if (k === "id" || k == "createdAt") continue;
144
- if (Object.hasOwn(this, k)) {
145
- (this as any)[k] = response[k as keyof APIGuildGroupedChannel];
146
- }
147
- }
148
-
149
- this.updatedAt = new Date();
150
- this.manager.cache.set(this.type, this);
151
- return this;
152
- }
153
- toJSON() {
154
- const json: Record<string, unknown> = {};
155
- for (const [key, value] of Object.entries(this)) {
156
- if (typeof value !== "function") {
157
- json[key] = value;
158
- }
159
- }
160
- return json;
161
- }
162
- toString() {
163
- return `${this.ids.length}`;
164
- }
165
- }
@@ -1,302 +0,0 @@
1
- import { GuildBetManager } from "../../managers/bet/GuildBetManager";
2
- import { GuildBetUserManager } from "../../managers/betuser/GuildBetUserManager";
3
- import { GroupedChannelManager } from "../../managers/groupedchannel/GroupedChannelManager";
4
- import { GuildMatchManager } from "../../managers/match/GuildMatchManager";
5
- import { GuildMediatorManager } from "../../managers/mediator/GuildMediatorManager";
6
- import { MessagesManager } from "../../managers/messages/MessagesManager";
7
- import { GuildPermissionManager } from "../../managers/permission/GuildPermissionManager";
8
- import { GuildTicketManager } from "../../managers/ticket/GuildTicketManager";
9
- import { GuildUserManager } from "../../managers/user/GuildUserManager";
10
- import { REST } from "../../rest/REST";
11
- import { Routes } from "../../rest/Routes";
12
- import { GuildBlacklist } from "../../types/api";
13
- import { APIBetMessage } from "../../types/api/APIBetMessage";
14
- import {
15
- APIGuild,
16
- GuildScores,
17
- GuildStatus,
18
- GuildTicketConfiguration,
19
- } from "../../types/api/APIGuild";
20
- import { APIGuildEmoji } from "../../types/api/APIGuildEmoji";
21
- import { APIGuildMediator } from "../../types/api/APIGuildMediator";
22
- import { APIGuildPermissions } from "../../types/api/APIGuildPermissions";
23
- import { APIGuildRole } from "../../types/api/APIGuildRole";
24
- import { APIGuildShop } from "../../types/api/APIGuildShop";
25
- import { APIGuildTicket } from "../../types/api/APIGuildTicket";
26
- import { APIGuildUser } from "../../types/api/APIGuildUser";
27
- import { Assertion } from "../../utils/Assertion";
28
- import { GuildBetUser } from "../betuser/GuildBetUser";
29
- import { GuildShop } from "../shop/GuildShop";
30
- import { GuildUser } from "../user/GuildUser";
31
-
32
- /** The Guild */
33
- export class Guild {
34
- /** The data of this guild */
35
- data: APIGuild;
36
-
37
- /** The rest client */
38
- rest: REST;
39
-
40
- /** The guild's id */
41
- id: string;
42
-
43
- /** Guild's client key */
44
- clientKey: string;
45
-
46
- /** Guild Permissions */
47
- permissions: APIGuildPermissions;
48
-
49
- /** Guild Ticket */
50
- tickets: GuildTicketManager;
51
-
52
- /** Guild Ticket Configuration */
53
- ticketsConfiguration: GuildTicketConfiguration;
54
-
55
- /** Guild Daily Categories */
56
- dailyCategories: ["coins", "credit"];
57
-
58
- /** Guild Scores */
59
- scores: GuildScores;
60
-
61
- /** Guild Status */
62
- status: GuildStatus;
63
-
64
- /** Guild Channel */
65
- channels: GroupedChannelManager;
66
-
67
- /** Guild Categories */
68
- categories: GroupedChannelManager;
69
-
70
- /** Guild Blacklist */
71
- blacklist: GuildBlacklist;
72
-
73
- /** Guild Prefix */
74
- prefix: string;
75
-
76
- /** Guild Prices */
77
- pricesAvailable: number[];
78
-
79
- /** Guild Prices Used */
80
- pricesOn: number[];
81
-
82
- /** Guild Creation Date */
83
- createdAt: Date;
84
-
85
- /** Guild Updated Date */
86
- updatedAt: Date;
87
-
88
- /** Guild Bets */
89
- bets: GuildBetManager;
90
-
91
- /** Guild Users */
92
- users: GuildUserManager;
93
-
94
- /** Guild Bet Users */
95
- betUsers: GuildBetUserManager;
96
-
97
- /** Guild Matches */
98
- matches: GuildMatchManager;
99
-
100
- /** Guild Mediators */
101
- mediators: GuildMediatorManager;
102
-
103
- /** Guild Messages */
104
- messages: MessagesManager;
105
-
106
- /** Guild Emojis */
107
- emojis: APIGuildEmoji[];
108
-
109
- /** Guild Roles */
110
- roles: APIGuildRole[];
111
-
112
- /** Guild Shop */
113
- shop: GuildShop;
114
-
115
- permissionsManager: GuildPermissionManager;
116
-
117
- /**
118
- * The guild structure
119
- * @param data The guild's data
120
- * @param rest The rest client
121
- */
122
- constructor(data: APIGuild, rest: REST) {
123
- this.data = data;
124
- this.rest = rest;
125
-
126
- this.id = data?.id;
127
- this.clientKey = data?.clientKey;
128
- this.prefix = data?.prefix;
129
- this.status = data?.status;
130
-
131
- this.ticketsConfiguration = data?.ticketsConfiguration;
132
- this.dailyCategories = data?.dailyCategories;
133
- this.scores = data?.scores;
134
-
135
- this.messages = new MessagesManager(this, this.id, rest);
136
- this.roles = data?.roles;
137
- this.emojis = data?.emojis;
138
-
139
- this.blacklist = data?.blacklist;
140
- this.pricesAvailable = data?.pricesAvailable;
141
- this.pricesOn = data?.pricesOn;
142
-
143
- this.shop = new GuildShop(data?.shop, this, rest);
144
-
145
- this.mediators = new GuildMediatorManager(this, rest);
146
- this.bets = new GuildBetManager(this, rest);
147
- this.users = new GuildUserManager(this, rest);
148
- this.betUsers = new GuildBetUserManager(this, rest);
149
- this.matches = new GuildMatchManager(this, rest);
150
- this.channels = new GroupedChannelManager(this, "channels", rest);
151
- this.categories = new GroupedChannelManager(this, "categories", rest);
152
- this.tickets = new GuildTicketManager(this, rest);
153
- this.permissionsManager = new GuildPermissionManager(this, rest);
154
-
155
- this.bets.setAll(data?.bets);
156
- this.users.setAll(data?.users);
157
- this.betUsers.setAll(data?.betUsers);
158
- this.channels.setAll(data?.channels);
159
- this.categories.setAll(data?.categories);
160
- this.matches.setAll(data?.matches);
161
- this.mediators.setAll(data?.mediators);
162
- this.tickets.setAll(data?.tickets);
163
- this.permissionsManager.setAll(data?.permissions);
164
- this.messages.setAll(data?.messages);
165
-
166
- this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
167
- this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
168
- }
169
-
170
- async fetch(): Promise<Guild> {
171
- const route = Routes.guilds.get(this.id);
172
- const response = await this.rest.request<APIGuild, {}>({
173
- method: "get",
174
- url: route,
175
- });
176
- const guild = new Guild(response, this.rest);
177
- this.rest.guilds.cache.set(guild.id, guild);
178
-
179
- return guild;
180
- }
181
-
182
- async setBlacklist(
183
- value: boolean,
184
- user: GuildBetUser | GuildUser,
185
- adminId: string
186
- ) {
187
- Assertion.assertBoolean(value);
188
- Assertion.assertString(adminId);
189
- const is_in_blacklist = this.blacklist.find((u) => u.id == user.id);
190
- if (is_in_blacklist && value == true) return this;
191
-
192
- const route = Routes.guilds.resource(this.id, "blacklist");
193
- const payload = { id: user.id, name: user.name, adminId, value };
194
-
195
- const [response] = await Promise.all([
196
- this.rest.request<APIGuild, typeof payload>({
197
- method: "PATCH",
198
- url: route,
199
- payload,
200
- }),
201
- user.setBlacklist(value),
202
- ]);
203
- this.blacklist = response.blacklist;
204
- this.rest.guilds.cache.set(this.id, this);
205
- this.rest.emit("guildUpdate", this);
206
- return this;
207
- }
208
- async setStatus(key: keyof GuildStatus, status: string) {
209
- Assertion.assertString(status);
210
-
211
- status = status.toLowerCase();
212
-
213
- const route = Routes.fields(Routes.guilds.resource(this.id, "status"), key);
214
- const payload = { status };
215
- const response = await this.rest.request<APIGuild, typeof payload>({
216
- method: "PATCH",
217
- url: route,
218
- payload,
219
- });
220
-
221
- this.status = response.status;
222
- this.rest.guilds.cache.set(this.id, this);
223
- this.rest.emit("guildUpdate", this);
224
- return this;
225
- }
226
- async addPrice(price: number) {
227
- Assertion.assertNumber(price);
228
-
229
- const route = Routes.fields(
230
- Routes.guilds.resource(this.id, "price"),
231
- "pricesOn"
232
- );
233
- const payload = { price };
234
- const response = await this.rest.request<APIGuild, typeof payload>({
235
- method: "PATCH",
236
- url: route,
237
- payload,
238
- });
239
- this.pricesAvailable = response.pricesAvailable;
240
- this.pricesOn = response.pricesOn;
241
- this.rest.guilds.cache.set(this.id, this);
242
- this.rest.emit("guildUpdate", this);
243
- return this;
244
- }
245
- async removePrice(price: number) {
246
- Assertion.assertNumber(price);
247
-
248
- const route = Routes.fields(
249
- Routes.guilds.resource(this.id, "price"),
250
- "pricesOn"
251
- );
252
- const payload = { price };
253
- const response = await this.rest.request<APIGuild, typeof payload>({
254
- method: "DELETE",
255
- url: route,
256
- payload,
257
- });
258
-
259
- this.pricesAvailable = response.pricesAvailable;
260
- this.pricesOn = response.pricesOn;
261
- this.rest.guilds.cache.set(this.id, this);
262
- this.rest.emit("guildUpdate", this);
263
- return this;
264
- }
265
-
266
- async setPrefix(prefix: string) {
267
- Assertion.assertString(prefix);
268
-
269
- const route = Routes.fields(Routes.guilds.resource(this.id, "prefix"));
270
- const payload = { prefix };
271
- const response = await this.rest.request<APIGuild, typeof payload>({
272
- method: "PATCH",
273
- url: route,
274
- payload,
275
- });
276
-
277
- this.prefix = response.prefix;
278
- this.rest.guilds.cache.set(this.id, this);
279
- this.rest.emit("guildUpdate", this);
280
- return this;
281
- }
282
- async addDailyCategory(category: string) {
283
- Assertion.assertString(category);
284
-
285
- const route = Routes.fields(
286
- Routes.guilds.resource(this.id, "dailyCategories")
287
- );
288
- const categories = [...new Set([...this.dailyCategories, category])];
289
-
290
- const payload = { categories };
291
- const response = await this.rest.request<APIGuild, typeof payload>({
292
- method: "PATCH",
293
- url: route,
294
- payload,
295
- });
296
-
297
- this.dailyCategories = response.dailyCategories;
298
- this.rest.guilds.cache.set(this.id, this);
299
- this.rest.emit("guildUpdate", this);
300
- return this;
301
- }
302
- }