disgroove 1.3.3 → 1.3.4-dev.7ed5475

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 (88) hide show
  1. package/dist/lib/Client.d.ts +11 -3
  2. package/dist/lib/Client.js +4 -4
  3. package/dist/lib/Client.js.map +1 -1
  4. package/dist/lib/constants.d.ts +2 -2
  5. package/dist/lib/constants.js +36 -36
  6. package/dist/lib/constants.js.map +1 -1
  7. package/dist/lib/gateway/Shard.js +2 -2
  8. package/dist/lib/rest/RequestsManager.d.ts +1 -1
  9. package/dist/lib/rest/RequestsManager.js +3 -4
  10. package/dist/lib/rest/RequestsManager.js.map +1 -1
  11. package/dist/lib/structures/Application.d.ts +13 -13
  12. package/dist/lib/structures/ApplicationCommand.d.ts +5 -5
  13. package/dist/lib/structures/ApplicationCommand.js.map +1 -1
  14. package/dist/lib/structures/ClientApplication.d.ts +13 -13
  15. package/dist/lib/structures/Guild.d.ts +14 -14
  16. package/dist/lib/structures/Guild.js +2 -3
  17. package/dist/lib/structures/Guild.js.map +1 -1
  18. package/dist/lib/structures/User.d.ts +3 -3
  19. package/dist/lib/types/application-command.d.ts +11 -11
  20. package/dist/lib/types/application-role-connection-metadata.d.ts +5 -5
  21. package/dist/package.json +1 -2
  22. package/package.json +1 -2
  23. package/lib/Client.ts +0 -616
  24. package/lib/constants.ts +0 -1173
  25. package/lib/gateway/Shard.ts +0 -704
  26. package/lib/gateway/ShardsManager.ts +0 -11
  27. package/lib/gateway/index.ts +0 -2
  28. package/lib/index.ts +0 -7
  29. package/lib/rest/CDN.ts +0 -56
  30. package/lib/rest/Endpoints.ts +0 -241
  31. package/lib/rest/REST.ts +0 -45
  32. package/lib/rest/RequestsManager.ts +0 -134
  33. package/lib/rest/index.ts +0 -4
  34. package/lib/structures/Application.ts +0 -599
  35. package/lib/structures/ApplicationCommand.ts +0 -187
  36. package/lib/structures/AuditLog.ts +0 -112
  37. package/lib/structures/AutoModerationRule.ts +0 -127
  38. package/lib/structures/Base.ts +0 -39
  39. package/lib/structures/Channel.ts +0 -921
  40. package/lib/structures/ClientApplication.ts +0 -515
  41. package/lib/structures/Emoji.ts +0 -95
  42. package/lib/structures/Entitlement.ts +0 -65
  43. package/lib/structures/Guild.ts +0 -1842
  44. package/lib/structures/GuildMember.ts +0 -193
  45. package/lib/structures/GuildScheduledEvent.ts +0 -164
  46. package/lib/structures/GuildTemplate.ts +0 -103
  47. package/lib/structures/Integration.ts +0 -136
  48. package/lib/structures/Interaction.ts +0 -506
  49. package/lib/structures/Invite.ts +0 -108
  50. package/lib/structures/Message.ts +0 -421
  51. package/lib/structures/Role.ts +0 -116
  52. package/lib/structures/SKU.ts +0 -63
  53. package/lib/structures/StageInstance.ts +0 -74
  54. package/lib/structures/Sticker.ts +0 -100
  55. package/lib/structures/Team.ts +0 -41
  56. package/lib/structures/TestEntitlement.ts +0 -78
  57. package/lib/structures/UnavailableGuild.ts +0 -27
  58. package/lib/structures/User.ts +0 -233
  59. package/lib/structures/VoiceState.ts +0 -72
  60. package/lib/structures/Webhook.ts +0 -341
  61. package/lib/structures/index.ts +0 -27
  62. package/lib/types/application-command.ts +0 -118
  63. package/lib/types/application-role-connection-metadata.ts +0 -23
  64. package/lib/types/application.ts +0 -77
  65. package/lib/types/audit-log.ts +0 -105
  66. package/lib/types/auto-moderation.ts +0 -78
  67. package/lib/types/channel.ts +0 -534
  68. package/lib/types/emoji.ts +0 -24
  69. package/lib/types/entitlements.ts +0 -34
  70. package/lib/types/gateway-events.ts +0 -970
  71. package/lib/types/guild-scheduled-event.ts +0 -67
  72. package/lib/types/guild-template.ts +0 -30
  73. package/lib/types/guild.ts +0 -388
  74. package/lib/types/index.ts +0 -23
  75. package/lib/types/interaction.ts +0 -224
  76. package/lib/types/invite.ts +0 -78
  77. package/lib/types/message-components.ts +0 -127
  78. package/lib/types/role.ts +0 -51
  79. package/lib/types/sku.ts +0 -32
  80. package/lib/types/stage-instance.ts +0 -22
  81. package/lib/types/sticker.ts +0 -67
  82. package/lib/types/team.ts +0 -34
  83. package/lib/types/user.ts +0 -93
  84. package/lib/types/voice.ts +0 -51
  85. package/lib/types/webhook.ts +0 -40
  86. package/lib/utils/Util.ts +0 -600
  87. package/lib/utils/errors.ts +0 -23
  88. package/lib/utils/index.ts +0 -2
@@ -1,515 +0,0 @@
1
- import {
2
- Base,
3
- ApplicationCommand,
4
- Application,
5
- SKU,
6
- Entitlement,
7
- TestEntitlement,
8
- } from ".";
9
- import type {
10
- JSONGuildApplicationCommandPermissions,
11
- RawApplication,
12
- RawGuildApplicationCommandPermissions,
13
- RawApplicationCommand,
14
- JSONApplication,
15
- JSONApplicationRoleConnectionMetadata,
16
- RawApplicationRoleConnectionMetadata,
17
- RawEntitlement,
18
- RawSKU,
19
- JSONInstallParams,
20
- JSONApplicationCommandOption,
21
- } from "../types";
22
- import type { Client } from "../Client";
23
- import { Endpoints } from "../rest";
24
- import type {
25
- ApplicationCommandTypes,
26
- ApplicationFlags,
27
- Locale,
28
- } from "../constants";
29
-
30
- export class ClientApplication extends Base {
31
- protected override raw: Pick<RawApplication, "id" | "flags">;
32
- flags?: ApplicationFlags;
33
-
34
- constructor(data: Pick<RawApplication, "id" | "flags">, client: Client) {
35
- super(data.id, client);
36
-
37
- this.raw = data;
38
-
39
- this.patch(data);
40
- }
41
-
42
- protected override patch(data: Pick<RawApplication, "id" | "flags">) {
43
- if (data.flags !== undefined) this.flags = data.flags;
44
- }
45
-
46
- /** https://discord.com/developers/docs/interactions/application-commands#create-global-application-command */
47
- async createGlobalApplicationCommand(options: {
48
- name: string;
49
- nameLocalizations?: Partial<Record<Locale, string>> | null;
50
- description?: string;
51
- descriptionLocalizations?: Partial<Record<Locale, string>> | null;
52
- options?: Array<JSONApplicationCommandOption>;
53
- defaultMemberPermissions?: string | null;
54
- dmPermission?: boolean;
55
- defaultPermission?: boolean | null;
56
- type?: ApplicationCommandTypes;
57
- nsfw?: boolean;
58
- }): Promise<ApplicationCommand> {
59
- return new ApplicationCommand(
60
- await this.client.rest.post<RawApplicationCommand>(
61
- Endpoints.applicationCommands(this.id),
62
- {
63
- json: this.client.util.applicationCommandToRaw(options),
64
- }
65
- ),
66
- this.client
67
- );
68
- }
69
-
70
- /** https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command */
71
- async createGuildApplicationCommand(
72
- guildId: string,
73
- options: {
74
- name?: string;
75
- nameLocalizations?: Partial<Record<Locale, string>> | null;
76
- description?: string;
77
- descriptionLocalizations?: Partial<Record<Locale, string>> | null;
78
- options?: Array<JSONApplicationCommandOption>;
79
- defaultMemberPermissions?: string | null;
80
- dmPermission?: boolean;
81
- defaultPermission?: boolean | null;
82
- type?: ApplicationCommandTypes;
83
- nsfw?: boolean;
84
- }
85
- ): Promise<ApplicationCommand> {
86
- return new ApplicationCommand(
87
- await this.client.rest.post<RawApplicationCommand>(
88
- Endpoints.applicationGuildCommands(this.id, guildId),
89
- {
90
- json: this.client.util.applicationCommandToRaw(options),
91
- }
92
- ),
93
- this.client
94
- );
95
- }
96
-
97
- /** https://discord.com/developers/docs/monetization/entitlements#create-test-entitlement */
98
- async createTestEntitlement(options: {
99
- skuId: string;
100
- ownerId: string;
101
- ownerType: number;
102
- }): Promise<TestEntitlement> {
103
- return new TestEntitlement(
104
- await this.client.rest.post<
105
- Omit<RawEntitlement, "starts_at" | "ends_at" | "subscription_id">
106
- >(Endpoints.applicationEntitlements(this.id), {
107
- json: {
108
- sku_id: options.skuId,
109
- owner_id: options.ownerId,
110
- owner_type: options.ownerType,
111
- },
112
- }),
113
- this.client
114
- );
115
- }
116
-
117
- /** https://discord.com/developers/docs/interactions/application-commands#delete-global-application-command */
118
- deleteGlobalApplicationCommand(commandId: string): void {
119
- this.client.rest.delete(Endpoints.applicationCommand(this.id, commandId));
120
- }
121
-
122
- /** https://discord.com/developers/docs/interactions/application-commands#delete-guild-application-command */
123
- deleteGuildApplicationCommand(guildId: string, commandId: string): void {
124
- this.client.rest.delete(
125
- Endpoints.applicationGuildCommand(this.id, guildId, commandId)
126
- );
127
- }
128
-
129
- /** https://discord.com/developers/docs/monetization/entitlements#delete-test-entitlement */
130
- deleteTestEntitlement(entitlementId: string): void {
131
- this.client.rest.delete(
132
- Endpoints.applicationEntitlement(this.id, entitlementId)
133
- );
134
- }
135
-
136
- /** https://discord.com/developers/docs/resources/application#edit-current-application */
137
- async edit(options: {
138
- customInstallURL?: string;
139
- description?: string;
140
- roleConnectionsVerificationURL?: string;
141
- installParams?: JSONInstallParams;
142
- flags?: ApplicationFlags;
143
- icon?: string;
144
- coverImage?: string;
145
- interactionsEndpointURL?: string;
146
- tags?: Array<string>;
147
- }): Promise<Application> {
148
- return new Application(
149
- await this.client.rest.patch<RawApplication>(
150
- Endpoints.applicationCurrentUser(),
151
- {
152
- json: {
153
- custom_install_url: options.customInstallURL,
154
- description: options.description,
155
- role_connections_verification_url:
156
- options.roleConnectionsVerificationURL,
157
- install_params: options.installParams,
158
- flags: options.flags,
159
- icon: options.icon,
160
- cover_image: options.coverImage,
161
- interactions_endpoint_url: options.interactionsEndpointURL,
162
- tags: options.tags,
163
- },
164
- }
165
- ),
166
- this.client
167
- );
168
- }
169
-
170
- /** https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions */
171
- async editApplicationCommandPermissions(
172
- guildId: string,
173
- commandId: string,
174
- options: {
175
- permissions: Array<JSONGuildApplicationCommandPermissions>;
176
- }
177
- ): Promise<JSONGuildApplicationCommandPermissions> {
178
- return this.client.rest
179
- .put<RawGuildApplicationCommandPermissions>(
180
- Endpoints.applicationCommandPermissions(this.id, guildId, commandId),
181
- {
182
- json: {
183
- permissions: options.permissions.map((option) => ({
184
- id: option.id,
185
- application_id: option.applicationId,
186
- guild_id: option.guildId,
187
- permissions: option.permissions.map((permission) => ({
188
- id: permission.id,
189
- type: permission.type,
190
- permission: permission.permission,
191
- })),
192
- })),
193
- },
194
- }
195
- )
196
- .then((response) => ({
197
- id: response.id,
198
- applicationId: response.application_id,
199
- guildId: response.guild_id,
200
- permissions: response.permissions.map((permission) => ({
201
- id: permission.id,
202
- type: permission.type,
203
- permission: permission.permission,
204
- })),
205
- }));
206
- }
207
-
208
- /** https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command */
209
- async editGlobalApplicationCommand(
210
- commandId: string,
211
- options: {
212
- name?: string;
213
- nameLocalizations?: Partial<Record<Locale, string>> | null;
214
- description?: string;
215
- descriptionLocalizations?: Partial<Record<Locale, string>> | null;
216
- options?: Array<JSONApplicationCommandOption>;
217
- defaultMemberPermissions?: string | null;
218
- defaultPermission?: boolean | null;
219
- dmPermission?: boolean;
220
- nsfw?: boolean;
221
- }
222
- ): Promise<ApplicationCommand> {
223
- return new ApplicationCommand(
224
- await this.client.rest.patch<RawApplicationCommand>(
225
- Endpoints.applicationCommand(this.id, commandId),
226
- {
227
- json: this.client.util.applicationCommandToRaw(options),
228
- }
229
- ),
230
- this.client
231
- );
232
- }
233
-
234
- /** https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command */
235
- async editGuildApplicationCommand(
236
- guildId: string,
237
- commandId: string,
238
- options: {
239
- name?: string;
240
- nameLocalizations?: Partial<Record<Locale, string>> | null;
241
- description?: string;
242
- descriptionLocalizations?: Partial<Record<Locale, string>> | null;
243
- options?: Array<JSONApplicationCommandOption>;
244
- defaultMemberPermissions?: string | null;
245
- defaultPermission?: boolean | null;
246
- dmPermission?: boolean;
247
- nsfw?: boolean;
248
- }
249
- ): Promise<ApplicationCommand> {
250
- return new ApplicationCommand(
251
- await this.client.rest.patch<RawApplicationCommand>(
252
- Endpoints.applicationGuildCommand(this.id, guildId, commandId),
253
- {
254
- json: this.client.util.applicationCommandToRaw(options),
255
- }
256
- ),
257
- this.client
258
- );
259
- }
260
-
261
- /** https://discord.com/developers/docs/interactions/application-commands#get-application-command-permissions */
262
- async getApplicationCommandPermissions(
263
- guildId: string,
264
- commandId: string
265
- ): Promise<Array<JSONGuildApplicationCommandPermissions>> {
266
- return this.client.rest
267
- .get<Array<RawGuildApplicationCommandPermissions>>(
268
- Endpoints.applicationCommandPermissions(this.id, guildId, commandId)
269
- )
270
- .then((response) =>
271
- response.map((permissions: RawGuildApplicationCommandPermissions) => ({
272
- id: permissions.id,
273
- applicationId: permissions.application_id,
274
- guildId: permissions.guild_id,
275
- permissions: permissions.permissions.map((permission) => ({
276
- id: permission.id,
277
- type: permission.type,
278
- permission: permission.permission,
279
- })),
280
- }))
281
- );
282
- }
283
-
284
- /** https://discord.com/developers/docs/monetization/entitlements#list-entitlements */
285
- async getEntitlements(options?: {
286
- userId?: string;
287
- skuIds?: Array<string>;
288
- before?: string;
289
- after?: string;
290
- limit?: number;
291
- guildId?: string;
292
- excludeEnded?: boolean;
293
- }): Promise<Array<Entitlement>> {
294
- return this.client.rest
295
- .get<Array<RawEntitlement>>(Endpoints.applicationEntitlements(this.id), {
296
- query: {
297
- user_id: options?.userId,
298
- sku_ids: options?.skuIds,
299
- before: options?.before,
300
- after: options?.after,
301
- limit: options?.limit,
302
- guild_id: options?.guildId,
303
- exclude_ended: options?.excludeEnded,
304
- },
305
- })
306
- .then((response) =>
307
- response.map((data) => new Entitlement(data, this.client))
308
- );
309
- }
310
-
311
- /** https://discord.com/developers/docs/interactions/application-commands#get-global-application-command */
312
- async getGlobalApplicationCommand(
313
- commandId: string
314
- ): Promise<ApplicationCommand> {
315
- return new ApplicationCommand(
316
- await this.client.rest.get<RawApplicationCommand>(
317
- Endpoints.applicationCommand(this.id, commandId)
318
- ),
319
- this.client
320
- );
321
- }
322
-
323
- /** https://discord.com/developers/docs/interactions/application-commands#get-global-application-commands */
324
- async getGlobalApplicationCommands(options: {
325
- withLocalizations?: boolean;
326
- }): Promise<Array<ApplicationCommand>> {
327
- return this.client.rest
328
- .get<Array<RawApplicationCommand>>(
329
- Endpoints.applicationCommands(this.id),
330
- {
331
- query: {
332
- with_localizations: options.withLocalizations,
333
- },
334
- }
335
- )
336
- .then((response) =>
337
- response.map((data) => new ApplicationCommand(data, this.client))
338
- );
339
- }
340
-
341
- /** https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command */
342
- async getGuildApplicationCommand(
343
- guildId: string,
344
- commandId: string
345
- ): Promise<ApplicationCommand> {
346
- return new ApplicationCommand(
347
- await this.client.rest.get<RawApplicationCommand>(
348
- Endpoints.applicationGuildCommand(this.id, guildId, commandId)
349
- ),
350
- this.client
351
- );
352
- }
353
-
354
- /** https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */
355
- async getGuildApplicationCommands(
356
- guildId: string,
357
- options?: {
358
- withLocalizations?: boolean;
359
- }
360
- ): Promise<Array<ApplicationCommand>> {
361
- return this.client.rest
362
- .get<Array<RawApplicationCommand>>(
363
- Endpoints.applicationGuildCommands(this.id, guildId),
364
- {
365
- query: {
366
- with_localizations: options?.withLocalizations,
367
- },
368
- }
369
- )
370
- .then((response) =>
371
- response.map((data) => new ApplicationCommand(data, this.client))
372
- );
373
- }
374
-
375
- /** https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command-permissions */
376
- async getGuildApplicationCommandPermissions(
377
- guildId: string
378
- ): Promise<Array<JSONGuildApplicationCommandPermissions>> {
379
- return this.client.rest
380
- .get<Array<RawGuildApplicationCommandPermissions>>(
381
- Endpoints.guildApplicationCommandsPermissions(this.id, guildId)
382
- )
383
- .then((response) =>
384
- response.map((permissions: RawGuildApplicationCommandPermissions) => ({
385
- id: permissions.id,
386
- applicationId: permissions.application_id,
387
- guildId: permissions.guild_id,
388
- permissions: permissions.permissions.map((permission) => ({
389
- id: permission.id,
390
- type: permission.type,
391
- permission: permission.permission,
392
- })),
393
- }))
394
- );
395
- }
396
-
397
- /** https://discord.com/developers/docs/resources/application-role-connection-metadata#get-application-role-connection-metadata-records */
398
- async getApplicationRoleConnectionMetadataRecords(): Promise<
399
- Array<JSONApplicationRoleConnectionMetadata>
400
- > {
401
- return this.client.rest
402
- .get<Array<RawApplicationRoleConnectionMetadata>>(
403
- Endpoints.applicationRoleConnectionMetadata(this.id)
404
- )
405
- .then((response) =>
406
- response.map((data) => ({
407
- type: data.type,
408
- key: data.key,
409
- name: data.name,
410
- nameLocalizations: data.name_localizations,
411
- description: data.description,
412
- descriptionLocalizations: data.description_localizations,
413
- }))
414
- );
415
- }
416
-
417
- /** https://discord.com/developers/docs/monetization/skus#list-skus */
418
- async getSKUs(): Promise<Array<SKU>> {
419
- return this.client.rest
420
- .get<Array<RawSKU>>(Endpoints.applicationSKUs(this.id))
421
- .then((response) => response.map((data) => new SKU(data, this.client)));
422
- }
423
-
424
- /** https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commands */
425
- async setGlobalApplicationCommands(
426
- commands: Array<{
427
- id?: string;
428
- name: string;
429
- nameLocalizations?: Partial<Record<Locale, string>> | null;
430
- description?: string;
431
- descriptionLocalizations?: Partial<Record<Locale, string>> | null;
432
- options?: Array<JSONApplicationCommandOption>;
433
- defaultMemberPermissions?: string | null;
434
- dmPermission?: boolean;
435
- defaultPermission?: boolean | null;
436
- type?: ApplicationCommandTypes;
437
- nsfw?: boolean;
438
- }>
439
- ): Promise<Array<ApplicationCommand>> {
440
- return this.client.rest
441
- .put<Array<RawApplicationCommand>>(
442
- Endpoints.applicationCommands(this.id),
443
- {
444
- json: commands.map((command) =>
445
- this.client.util.applicationCommandToRaw(command)
446
- ),
447
- }
448
- )
449
- .then((response) =>
450
- response.map((data) => new ApplicationCommand(data, this.client))
451
- );
452
- }
453
-
454
- /** https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands */
455
- async setGuildApplicationCommands(
456
- guildId: string,
457
- commands: Array<{
458
- id?: string;
459
- name?: string;
460
- nameLocalizations?: Partial<Record<Locale, string>> | null;
461
- description?: string;
462
- descriptionLocalizations?: Partial<Record<Locale, string>> | null;
463
- options?: Array<JSONApplicationCommandOption>;
464
- defaultMemberPermissions?: string | null;
465
- dmPermission?: boolean;
466
- defaultPermission?: boolean | null;
467
- type: ApplicationCommandTypes;
468
- nsfw?: boolean;
469
- }>
470
- ): Promise<Array<ApplicationCommand>> {
471
- return this.client.rest
472
- .put<Array<RawApplicationCommand>>(
473
- Endpoints.applicationGuildCommands(this.id, guildId),
474
- {
475
- json: commands.map((command) =>
476
- this.client.util.applicationCommandToRaw(command)
477
- ),
478
- }
479
- )
480
- .then((response) =>
481
- response.map((data) => new ApplicationCommand(data, this.client))
482
- );
483
- }
484
-
485
- /** https://discord.com/developers/docs/resources/application-role-connection-metadata#update-application-role-connection-metadata-records */
486
- async updateApplicationRoleConnectionMetadataRecords(): Promise<
487
- Array<JSONApplicationRoleConnectionMetadata>
488
- > {
489
- return this.client.rest
490
- .put<Array<RawApplicationRoleConnectionMetadata>>(
491
- Endpoints.applicationRoleConnectionMetadata(this.id)
492
- )
493
- .then((response) =>
494
- response.map((data) => ({
495
- type: data.type,
496
- key: data.key,
497
- name: data.name,
498
- nameLocalizations: data.name_localizations,
499
- description: data.description,
500
- descriptionLocalizations: data.description_localizations,
501
- }))
502
- );
503
- }
504
-
505
- override toRaw(): Pick<RawApplication, "id" | "flags"> {
506
- return this.raw;
507
- }
508
-
509
- override toJSON(): Pick<JSONApplication, "id" | "flags"> {
510
- return {
511
- ...super.toJSON(),
512
- flags: this.flags,
513
- };
514
- }
515
- }
@@ -1,95 +0,0 @@
1
- import { User } from ".";
2
- import type { Client } from "../Client";
3
- import { Endpoints } from "../rest";
4
- import type { JSONEmoji, RawEmoji } from "../types";
5
-
6
- /** https://discord.com/developers/docs/resources/emoji */
7
- export class Emoji {
8
- private client: Client;
9
- private raw: RawEmoji;
10
- id: string | null;
11
- name: string | null;
12
- roles?: Array<string>;
13
- user?: User;
14
- requireColons?: boolean;
15
- managed?: boolean;
16
- animated?: boolean;
17
- available?: boolean;
18
-
19
- constructor(data: RawEmoji, client: Client) {
20
- this.client = client;
21
- this.raw = data;
22
- this.id = data.id;
23
- this.name = data.name;
24
-
25
- this.patch(data);
26
- }
27
-
28
- private patch(data: RawEmoji) {
29
- if (data.roles !== undefined) this.roles = data.roles;
30
- if (data.user !== undefined) this.user = new User(data.user, this.client);
31
- if (data.require_colons !== undefined)
32
- this.requireColons = data.require_colons;
33
- if (data.managed !== undefined) this.managed = data.managed;
34
- if (data.animated !== undefined) this.animated = data.animated;
35
- if (data.available !== undefined) this.available = data.available;
36
- }
37
-
38
- /** https://discord.com/developers/docs/resources/emoji#delete-guild-emoji */
39
- delete(guildId: string, reason?: string): void {
40
- if (!this.id)
41
- throw new Error("[disgroove] Cannot delete a default Discord emoji");
42
-
43
- this.client.rest.delete(Endpoints.guildEmoji(guildId, this.id), {
44
- reason,
45
- });
46
- }
47
-
48
- /** https://discord.com/developers/docs/resources/emoji#modify-guild-emoji */
49
- async edit(
50
- guildId: string,
51
- options: {
52
- name?: string;
53
- roles?: Array<string> | null;
54
- },
55
- reason?: string
56
- ): Promise<Emoji> {
57
- if (!this.id)
58
- throw new Error("[disgroove] Cannot edit a default Discord emoji");
59
-
60
- return new Emoji(
61
- await this.client.rest.patch<RawEmoji>(
62
- Endpoints.guildEmoji(guildId, this.id),
63
- {
64
- json: {
65
- name: options.name,
66
- roles: options.roles,
67
- },
68
- reason,
69
- }
70
- ),
71
- this.client
72
- );
73
- }
74
-
75
- toString(): string {
76
- return `[${this.constructor.name}]`;
77
- }
78
-
79
- toRaw(): RawEmoji {
80
- return this.raw;
81
- }
82
-
83
- toJSON(): JSONEmoji {
84
- return {
85
- id: this.id,
86
- name: this.name,
87
- roles: this.roles,
88
- user: this.user?.toJSON(),
89
- requireColons: this.requireColons,
90
- managed: this.managed,
91
- animated: this.animated,
92
- available: this.available,
93
- };
94
- }
95
- }
@@ -1,65 +0,0 @@
1
- import type { Client } from "../Client";
2
- import type { JSONEntitlement, RawEntitlement } from "../types";
3
- import { Base } from ".";
4
- import type { EntitlementTypes } from "../constants";
5
-
6
- /** https://discord.com/developers/docs/monetization/entitlements */
7
- export class Entitlement extends Base {
8
- protected override raw: RawEntitlement;
9
- skuId: string;
10
- applicationId: string;
11
- userId?: string;
12
- promotionId?: string | null; // Undocumented
13
- type: EntitlementTypes;
14
- deleted: boolean;
15
- giftCodeFlags?: number; // Undocumented
16
- consumed?: boolean; // Undocumented
17
- startsAt?: string;
18
- endsAt?: string;
19
- guildId?: string;
20
- subscriptionId?: string; // Undocumented
21
-
22
- constructor(data: RawEntitlement, client: Client) {
23
- super(data.id, client);
24
-
25
- this.raw = data;
26
- this.skuId = data.sku_id;
27
- this.applicationId = data.application_id;
28
- this.type = data.type;
29
- this.deleted = data.deleted;
30
- }
31
-
32
- protected override patch(data: RawEntitlement): void {
33
- if (data.user_id !== undefined) this.userId = data.user_id;
34
- if (data.promotion_id !== undefined) this.promotionId = data.promotion_id;
35
- if (data.gift_code_flags !== undefined)
36
- this.giftCodeFlags = data.gift_code_flags;
37
- if (data.consumed !== undefined) this.consumed = data.consumed;
38
- if (data.starts_at !== undefined) this.startsAt = data.starts_at;
39
- if (data.ends_at !== undefined) this.endsAt = data.ends_at;
40
- if (data.guild_id !== undefined) this.guildId = data.guild_id;
41
- if (data.subscription_id !== undefined) this.subscriptionId;
42
- }
43
-
44
- override toRaw(): RawEntitlement {
45
- return this.raw;
46
- }
47
-
48
- override toJSON(): JSONEntitlement {
49
- return {
50
- id: this.id,
51
- skuId: this.skuId,
52
- applicationId: this.applicationId,
53
- userId: this.userId,
54
- promotionId: this.promotionId,
55
- type: this.type,
56
- deleted: this.deleted,
57
- giftCodeFlags: this.giftCodeFlags,
58
- consumed: this.consumed,
59
- startsAt: this.startsAt,
60
- endsAt: this.endsAt,
61
- guildId: this.guildId,
62
- subscriptionId: this.subscriptionId,
63
- };
64
- }
65
- }