@duque.edits/sdk 0.0.3 → 0.0.5

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 (157) hide show
  1. package/{src/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 +89 -0
  44. package/dist/structures/guild/Guild.js +223 -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 +209 -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 +92 -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/{src/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 +5 -1
  104. package/.gitattributes +0 -2
  105. package/src/managers/bet/GuildBetManager.ts +0 -117
  106. package/src/managers/betuser/GuildBetUserManager.ts +0 -103
  107. package/src/managers/channel/ChannelManager.ts +0 -168
  108. package/src/managers/groupedchannel/GroupedChannelManager.ts +0 -117
  109. package/src/managers/guild/GuildManager.ts +0 -84
  110. package/src/managers/match/GuildMatchManager.ts +0 -115
  111. package/src/managers/mediator/GuildMediatorManager.ts +0 -111
  112. package/src/managers/messages/MessagesManager.ts +0 -95
  113. package/src/managers/permission/GuildPermissionManager.ts +0 -88
  114. package/src/managers/product/GuildProductManager.ts +0 -115
  115. package/src/managers/ticket/GuildTicketManager.ts +0 -112
  116. package/src/managers/user/GuildUserManager.ts +0 -116
  117. package/src/rest/APIEndpoints.ts +0 -11
  118. package/src/rest/REST.ts +0 -126
  119. package/src/rest/Routes.ts +0 -143
  120. package/src/structures/Collection.ts +0 -85
  121. package/src/structures/bet/GuildBet.ts +0 -332
  122. package/src/structures/betuser/GuildBetUser.ts +0 -247
  123. package/src/structures/channel/Channel.ts +0 -78
  124. package/src/structures/groupedchannel/GroupedChannel.ts +0 -165
  125. package/src/structures/guild/Guild.ts +0 -302
  126. package/src/structures/match/GuildMatch.ts +0 -385
  127. package/src/structures/mediator/GuildMediator.ts +0 -175
  128. package/src/structures/product/GuildProduct.ts +0 -217
  129. package/src/structures/shop/GuildShop.ts +0 -98
  130. package/src/structures/ticket/GuildTicket.ts +0 -227
  131. package/src/structures/user/GuildUser.ts +0 -248
  132. package/src/types/api/APIBaseChannel.ts +0 -13
  133. package/src/types/api/APIBetChannel.ts +0 -13
  134. package/src/types/api/APIBetMessage.ts +0 -13
  135. package/src/types/api/APIGuild.ts +0 -123
  136. package/src/types/api/APIGuildBet.ts +0 -69
  137. package/src/types/api/APIGuildBetUser.ts +0 -46
  138. package/src/types/api/APIGuildChannel.ts +0 -13
  139. package/src/types/api/APIGuildEmoji.ts +0 -16
  140. package/src/types/api/APIGuildGroupedChannel.ts +0 -13
  141. package/src/types/api/APIGuildMatch.ts +0 -67
  142. package/src/types/api/APIGuildMediator.ts +0 -18
  143. package/src/types/api/APIGuildMessage.ts +0 -13
  144. package/src/types/api/APIGuildPermissions.ts +0 -7
  145. package/src/types/api/APIGuildRole.ts +0 -13
  146. package/src/types/api/APIGuildShop.ts +0 -15
  147. package/src/types/api/APIGuildTicket.ts +0 -36
  148. package/src/types/api/APIGuildUser.ts +0 -45
  149. package/src/types/api/APIMessage.ts +0 -16
  150. package/src/types/api/APIPlayer.ts +0 -13
  151. package/src/types/api/APIProduct.ts +0 -27
  152. package/src/types/api/index.ts +0 -180
  153. package/src/utils/Assertion.ts +0 -56
  154. package/src/v1/managers/channel/ChannelManager.ts +0 -167
  155. package/src/v1/managers/match/GuildMatchManager.ts +0 -114
  156. package/tests/index.ts +0 -86
  157. package/tsconfig.json +0 -15
@@ -1,247 +0,0 @@
1
- import { REST } from "../../rest/REST";
2
- import { Routes } from "../../rest/Routes";
3
- import { Daily, Items, Optional, ProfileCard } from "../../types/api";
4
- import { APIGuildBetUser } from "../../types/api/APIGuildBetUser";
5
- import { GuildBetUserManager } from "../../managers/betuser/GuildBetUserManager";
6
-
7
- export class GuildBetUser implements APIGuildBetUser {
8
- /** User daily */
9
- daily: Omit<Daily, "points">;
10
-
11
- /** User's name */
12
- name: string;
13
-
14
- /** User's name */
15
- id: string;
16
-
17
- /** User's credit */
18
- credit: number;
19
-
20
- /** User's wins */
21
- wins: number;
22
-
23
- /** User's mvps */
24
- mvps: number;
25
-
26
- /** User's losses */
27
- losses: number;
28
-
29
- /** User's bets played */
30
- betsPlayed: string[];
31
-
32
- /** User's blacklist */
33
- blacklist: boolean;
34
-
35
- /** User's coins */
36
- coins: number;
37
-
38
- /** User's items */
39
- items: Items;
40
-
41
- /** User's profile card */
42
- profileCard: ProfileCard;
43
-
44
- /** Creation Date */
45
- createdAt: Date;
46
-
47
- /** Updated Date */
48
- updatedAt: Date;
49
-
50
- /** The given manager */
51
- readonly manager: GuildBetUserManager;
52
-
53
- /** The rest client */
54
- readonly rest: REST;
55
-
56
- /**
57
- * Bet user
58
- * @param data The user's data
59
- * @param manager The manager
60
- * @param rest The rest client
61
- */
62
- constructor(data: APIGuildBetUser, manager: GuildBetUserManager, rest: REST) {
63
- this.name = data.name;
64
- this.id = data.id;
65
- this.credit = data.credit;
66
- this.wins = data.wins;
67
- this.mvps = data.mvps;
68
- this.losses = data.losses;
69
- this.coins = data.coins;
70
- this.blacklist = data.blacklist;
71
- this.items = data.items;
72
- this.betsPlayed = data.betsPlayed;
73
- this.profileCard = data.profileCard;
74
- this.daily = data?.daily;
75
-
76
- this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
77
- this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
78
-
79
- this.manager = manager;
80
- this.rest = rest;
81
- }
82
- /** String representation of this user */
83
- toString() {
84
- return `<@${this.id}>`;
85
- }
86
- /**
87
- * Fetches the user
88
- * @returns New Instance of the user
89
- */
90
- async fetch() {
91
- const route = Routes.guilds.betUsers.get(this.manager.guild.id, this.id);
92
- const response = await this.rest.request<APIGuildBetUser, {}>({
93
- method: "get",
94
- url: route,
95
- });
96
- const user = new GuildBetUser(response, this.manager, this.rest);
97
-
98
- this.manager.cache.set(user.id, user);
99
- this.rest.betUsers.set(user.id, user);
100
- return user;
101
- }
102
-
103
- /**
104
- * Add a propery
105
- * @param key The desired key
106
- * @param value The desired value
107
- * @returns GuildBetUser
108
- */
109
- async add<K extends keyof BetUserAddOptions, V extends BetUserAddOptions[K]>(
110
- key: K,
111
- value: V
112
- ) {
113
- const route = Routes.guilds.betUsers.resource(
114
- this.manager.guild.id,
115
- this.id,
116
- key
117
- );
118
- const payload = { [key]: value, name: this.name };
119
-
120
- const resp = await this.rest.request<APIGuildBetUser, typeof payload>({
121
- method: "patch",
122
- url: route,
123
- payload,
124
- });
125
-
126
- this[key] = resp[key];
127
- this.manager.cache.set(this.id, this);
128
- this.rest.betUsers.set(this.id, this);
129
- return this;
130
- }
131
-
132
- /**
133
- * Set the user blacklist
134
- * @param value Value to set to
135
- * @returns GuildBetUser
136
- */
137
- async setBlacklist(value: boolean) {
138
- const route = Routes.guilds.betUsers.resource(
139
- this.manager.guild.id,
140
- this.id,
141
- "blacklist"
142
- );
143
- const payload = { value, name: this.name };
144
- await this.rest.request<APIGuildBetUser, typeof payload>({
145
- method: "patch",
146
- url: route,
147
- payload,
148
- });
149
- this.blacklist = value;
150
- this.manager.cache.set(this.id, this);
151
- this.rest.betUsers.set(this.id, this);
152
- return this;
153
- }
154
-
155
- /**
156
- * Update certain property
157
- * @param data The new data to update with
158
- * @returns
159
- */
160
- async update(
161
- data: Omit<Optional<APIGuildBetUser>, "daily"> & { type?: "add" | "remove" }
162
- ) {
163
- const route = Routes.guilds.betUsers.get(this.manager.guild.id, this.id);
164
- const payload: Record<string, any> = {};
165
-
166
- const numericFields = [
167
- "coins",
168
- "wins",
169
- "credit",
170
- "losses",
171
- "mvps",
172
- ] as const;
173
- const arrayFields = ["items", "betsPlayed"] as const;
174
-
175
- if (data.type === "add" || data.type === "remove") {
176
- for (const key in data) {
177
- if (key === "type") continue;
178
-
179
- const value = data[key as keyof typeof data];
180
-
181
- if (numericFields.includes(key as any)) {
182
- const current = this[key as keyof typeof this] as number;
183
- const num = value as number;
184
- payload[key] = Math.max(
185
- 0,
186
- data.type === "add" ? current + num : num - current
187
- );
188
- } else if (key === "blacklist") {
189
- payload["blacklist"] = value;
190
- } else if (arrayFields.includes(key as any)) {
191
- const current = this[key as keyof typeof this] as any[];
192
- const incoming = value as any[];
193
-
194
- payload[key] =
195
- data.type === "add"
196
- ? [...new Set([...current, ...incoming])]
197
- : current.filter((x) => !incoming.includes(x));
198
- }
199
- }
200
- }
201
-
202
- const response = await this.rest.request<APIGuildBetUser, typeof payload>({
203
- method: "patch",
204
- url: route,
205
- payload,
206
- });
207
-
208
- for (const k in response) {
209
- if (k === "id") continue;
210
- if (Object.hasOwn(this, k)) {
211
- (this as any)[k] = response[k as keyof APIGuildBetUser];
212
- }
213
- }
214
- this.rest.betUsers.set(this.id, this);
215
- this.manager.cache.set(this.id, this);
216
- return this;
217
- }
218
- async delete() {
219
- const route = Routes.guilds.betUsers.delete(this.manager.guild.id, this.id);
220
- const response = await this.rest.request<boolean, {}>({
221
- method: "DELETE",
222
- url: route,
223
- });
224
-
225
- this.rest.emit("betUserDelete", this);
226
- this.manager.cache.delete(this.id);
227
- this.rest.betUsers.set(this.id, this);
228
- return response;
229
- }
230
- toJSON() {
231
- const json: Record<string, unknown> = {};
232
- for (const [key, value] of Object.entries(this)) {
233
- if (typeof value !== "function") {
234
- json[key] = value;
235
- }
236
- }
237
- return json;
238
- }
239
- }
240
-
241
- export type BetUserAddOptions = {
242
- coins: number;
243
- credit: number;
244
- wins: number;
245
- losses: number;
246
- mvps: number;
247
- };
@@ -1,78 +0,0 @@
1
- import { ChannelManager } from "../../managers/channel/ChannelManager";
2
- import { REST } from "../../rest/REST";
3
- import { APIBaseChannel } from "../../types/api/APIBaseChannel";
4
- import { APIBetChannel } from "../../types/api/APIBetChannel";
5
- import { Assertion } from "../../utils/Assertion";
6
- import { GuildBet } from "../bet/GuildBet";
7
- import { Guild } from "../guild/Guild";
8
- import { GuildMatch } from "../match/GuildMatch";
9
-
10
- export interface ChannelData<S extends GuildBet | GuildMatch> {
11
- baseUrl: string;
12
-
13
- data: APIBaseChannel;
14
- guild: Guild;
15
- manager: ChannelManager<S>;
16
- }
17
- export class Channel<S extends GuildBet | GuildMatch> {
18
- /** Channel's type */
19
- type: string;
20
-
21
- /** Channel's id */
22
- id: string;
23
-
24
- /** Creation Date */
25
- createdAt: Date;
26
-
27
- /** Updated Date */
28
- updatedAt: Date;
29
-
30
- data: ChannelData<S>;
31
- rest: REST;
32
- baseUrl: string;
33
- guild: Guild;
34
- manager: ChannelManager<S>;
35
- constructor(data: ChannelData<S>, rest: REST) {
36
- this.type = data?.data?.type;
37
- this.id = data?.data?.id;
38
- this.createdAt = data?.data?.createdAt
39
- ? new Date(data?.data?.createdAt)
40
- : new Date();
41
- this.updatedAt = data?.data?.updatedAt
42
- ? new Date(data?.data?.updatedAt)
43
- : new Date();
44
-
45
- this.guild = data?.guild;
46
-
47
- this.manager = data?.manager;
48
- this.baseUrl = data.baseUrl;
49
-
50
- this.data = data;
51
- this.rest = rest;
52
- }
53
- toString() {
54
- return `<#${this.id}>`;
55
- }
56
- async setId(id: string) {
57
- Assertion.assertString(id);
58
-
59
- const payload = { id };
60
- const response = await this.rest.request<APIBetChannel, typeof payload>({
61
- method: "PATCH",
62
- url: this.baseUrl,
63
- payload,
64
- });
65
-
66
- this.id = response.id;
67
- return this;
68
- }
69
- async delete() {
70
- await this.rest.request<APIBetChannel, {}>({
71
- method: "delete",
72
- url: this.baseUrl,
73
- });
74
-
75
- this.manager.cache.delete(this.type);
76
- return this;
77
- }
78
- }
@@ -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
- }