seyfert 4.5.0 → 4.6.0

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 (175) hide show
  1. package/lib/api/Routes/guilds.d.ts +12 -1
  2. package/lib/api/Routes/index.d.ts +3 -1
  3. package/lib/api/Routes/invites.d.ts +1 -1
  4. package/lib/api/Routes/oauth2.d.ts +11 -0
  5. package/lib/api/Routes/oauth2.js +2 -0
  6. package/lib/api/Routes/skus.d.ts +11 -4
  7. package/lib/api/Routes/users.d.ts +2 -1
  8. package/lib/api/Routes/voice.d.ts +4 -0
  9. package/lib/api/Routes/webhooks.d.ts +1 -1
  10. package/lib/api/api.d.ts +15 -5
  11. package/lib/api/api.js +243 -114
  12. package/lib/api/bucket.js +13 -7
  13. package/lib/api/shared.d.ts +3 -1
  14. package/lib/api/utils/constants.d.ts +1 -1
  15. package/lib/api/utils/constants.js +1 -1
  16. package/lib/builders/Attachment.d.ts +6 -1
  17. package/lib/builders/Attachment.js +13 -9
  18. package/lib/builders/CheckboxGroup.js +1 -1
  19. package/lib/builders/FileUpload.d.ts +8 -1
  20. package/lib/builders/FileUpload.js +9 -0
  21. package/lib/builders/RadioGroup.js +1 -1
  22. package/lib/client/base.d.ts +3 -3
  23. package/lib/client/collectors.d.ts +10 -8
  24. package/lib/client/transformers.d.ts +5 -0
  25. package/lib/client/workerclient.d.ts +8 -1
  26. package/lib/client/workerclient.js +28 -9
  27. package/lib/commands/applications/chat.d.ts +6 -4
  28. package/lib/commands/applications/options.d.ts +6 -4
  29. package/lib/commands/applications/shared.d.ts +2 -2
  30. package/lib/commands/handle.d.ts +7 -3
  31. package/lib/commands/handle.js +36 -11
  32. package/lib/commands/handler.js +11 -0
  33. package/lib/commands/optionresolver.d.ts +6 -7
  34. package/lib/common/it/error.d.ts +13 -0
  35. package/lib/common/it/error.js +15 -1
  36. package/lib/common/it/logger.js +12 -9
  37. package/lib/common/shorters/application.d.ts +1 -1
  38. package/lib/common/shorters/application.js +1 -1
  39. package/lib/common/shorters/bans.js +1 -1
  40. package/lib/common/shorters/guilds.js +5 -1
  41. package/lib/common/shorters/interaction.js +7 -4
  42. package/lib/common/shorters/invites.d.ts +5 -0
  43. package/lib/common/shorters/members.js +2 -1
  44. package/lib/common/shorters/messages.js +2 -2
  45. package/lib/common/shorters/threads.js +1 -1
  46. package/lib/common/shorters/webhook.js +3 -3
  47. package/lib/common/types/util.d.ts +7 -0
  48. package/lib/components/componentcommand.js +2 -2
  49. package/lib/components/customId.d.ts +3 -0
  50. package/lib/components/customId.js +11 -0
  51. package/lib/components/handler.js +2 -3
  52. package/lib/components/modalcommand.js +2 -2
  53. package/lib/events/hooks/invite.d.ts +1 -0
  54. package/lib/events/hooks/presence.d.ts +1 -0
  55. package/lib/events/hooks/thread.d.ts +1 -0
  56. package/lib/structures/AnonymousGuild.d.ts +1 -1
  57. package/lib/structures/AnonymousGuild.js +1 -1
  58. package/lib/structures/Guild.d.ts +3 -0
  59. package/lib/structures/GuildMember.d.ts +2 -2
  60. package/lib/structures/GuildMember.js +22 -4
  61. package/lib/structures/GuildPreview.d.ts +1 -1
  62. package/lib/structures/GuildPreview.js +1 -1
  63. package/lib/structures/GuildRole.d.ts +13 -0
  64. package/lib/structures/GuildRole.js +21 -0
  65. package/lib/structures/GuildTemplate.js +1 -1
  66. package/lib/structures/Interaction.d.ts +7 -7
  67. package/lib/structures/Interaction.js +35 -21
  68. package/lib/structures/Message.d.ts +2 -1
  69. package/lib/structures/channels.d.ts +29 -16
  70. package/lib/structures/channels.js +59 -19
  71. package/lib/structures/extra/BaseGuild.d.ts +4 -4
  72. package/lib/structures/extra/BaseGuild.js +4 -4
  73. package/lib/types/gateway.d.ts +243 -239
  74. package/lib/types/index.d.ts +2 -2
  75. package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/attachment.d.ts +5 -2
  76. package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/shared.d.ts +2 -2
  77. package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/shared.js +1 -1
  78. package/lib/types/payloads/_interactions/_applicationCommands/chatInput.d.ts +7 -7
  79. package/lib/types/payloads/_interactions/_applicationCommands/contextMenu.d.ts +13 -13
  80. package/lib/types/payloads/_interactions/_applicationCommands/permissions.d.ts +4 -4
  81. package/lib/types/payloads/_interactions/_applicationCommands/permissions.js +2 -2
  82. package/lib/types/payloads/_interactions/applicationCommands.d.ts +10 -10
  83. package/lib/types/payloads/_interactions/applicationCommands.js +4 -4
  84. package/lib/types/payloads/_interactions/autocomplete.d.ts +2 -2
  85. package/lib/types/payloads/_interactions/base.d.ts +13 -7
  86. package/lib/types/payloads/_interactions/modalSubmit.d.ts +4 -4
  87. package/lib/types/payloads/_interactions/responses.d.ts +10 -10
  88. package/lib/types/payloads/_interactions/responses.js +2 -2
  89. package/lib/types/payloads/application.d.ts +21 -15
  90. package/lib/types/payloads/application.js +7 -7
  91. package/lib/types/payloads/auditLog.d.ts +22 -17
  92. package/lib/types/payloads/auditLog.js +7 -2
  93. package/lib/types/payloads/autoModeration.d.ts +11 -11
  94. package/lib/types/payloads/autoModeration.js +5 -5
  95. package/lib/types/payloads/channel.d.ts +87 -78
  96. package/lib/types/payloads/channel.js +16 -11
  97. package/lib/types/payloads/components.d.ts +41 -31
  98. package/lib/types/payloads/components.js +9 -5
  99. package/lib/types/payloads/emoji.d.ts +2 -2
  100. package/lib/types/payloads/emoji.js +1 -1
  101. package/lib/types/payloads/gateway.d.ts +33 -29
  102. package/lib/types/payloads/gateway.js +5 -5
  103. package/lib/types/payloads/guild.d.ts +68 -68
  104. package/lib/types/payloads/guild.js +14 -14
  105. package/lib/types/payloads/guildScheduledEvent.d.ts +11 -11
  106. package/lib/types/payloads/guildScheduledEvent.js +3 -3
  107. package/lib/types/payloads/index.d.ts +2 -2
  108. package/lib/types/payloads/interactions.d.ts +3 -3
  109. package/lib/types/payloads/invite.d.ts +11 -11
  110. package/lib/types/payloads/invite.js +3 -3
  111. package/lib/types/payloads/monetization.d.ts +4 -4
  112. package/lib/types/payloads/monetization.js +2 -2
  113. package/lib/types/payloads/oauth2.d.ts +21 -17
  114. package/lib/types/payloads/oauth2.js +21 -17
  115. package/lib/types/payloads/permissions.d.ts +5 -5
  116. package/lib/types/payloads/permissions.js +2 -2
  117. package/lib/types/payloads/poll.d.ts +7 -7
  118. package/lib/types/payloads/poll.js +2 -2
  119. package/lib/types/payloads/soundboard.d.ts +2 -2
  120. package/lib/types/payloads/soundboard.js +1 -1
  121. package/lib/types/payloads/stageInstance.d.ts +5 -5
  122. package/lib/types/payloads/stageInstance.js +1 -1
  123. package/lib/types/payloads/sticker.d.ts +8 -8
  124. package/lib/types/payloads/sticker.js +3 -3
  125. package/lib/types/payloads/teams.d.ts +8 -8
  126. package/lib/types/payloads/teams.js +3 -3
  127. package/lib/types/payloads/template.d.ts +3 -3
  128. package/lib/types/payloads/template.js +1 -1
  129. package/lib/types/payloads/user.d.ts +24 -22
  130. package/lib/types/payloads/user.js +7 -5
  131. package/lib/types/payloads/voice.d.ts +4 -4
  132. package/lib/types/payloads/voice.js +1 -1
  133. package/lib/types/payloads/webhokEvents.d.ts +5 -5
  134. package/lib/types/payloads/webhokEvents.js +2 -2
  135. package/lib/types/payloads/webhook.d.ts +4 -4
  136. package/lib/types/payloads/webhook.js +1 -1
  137. package/lib/types/rest/application.d.ts +14 -14
  138. package/lib/types/rest/auditLog.d.ts +1 -1
  139. package/lib/types/rest/autoModeration.d.ts +7 -7
  140. package/lib/types/rest/channel.d.ts +79 -74
  141. package/lib/types/rest/channel.js +1 -1
  142. package/lib/types/rest/emoji.d.ts +8 -8
  143. package/lib/types/rest/gateway.d.ts +2 -2
  144. package/lib/types/rest/guild.d.ts +98 -98
  145. package/lib/types/rest/guild.js +5 -5
  146. package/lib/types/rest/guildScheduledEvent.d.ts +11 -11
  147. package/lib/types/rest/index.d.ts +34 -3
  148. package/lib/types/rest/index.js +33 -2
  149. package/lib/types/rest/interactions.d.ts +48 -48
  150. package/lib/types/rest/invite.d.ts +5 -5
  151. package/lib/types/rest/monetization.d.ts +9 -9
  152. package/lib/types/rest/monetization.js +1 -1
  153. package/lib/types/rest/oauth2.d.ts +22 -18
  154. package/lib/types/rest/poll.d.ts +4 -4
  155. package/lib/types/rest/soundboard.d.ts +8 -8
  156. package/lib/types/rest/stageInstance.d.ts +6 -6
  157. package/lib/types/rest/sticker.d.ts +10 -10
  158. package/lib/types/rest/template.d.ts +11 -11
  159. package/lib/types/rest/user.d.ts +18 -14
  160. package/lib/types/rest/voice.d.ts +5 -5
  161. package/lib/types/rest/webhook.d.ts +38 -38
  162. package/lib/types/utils/index.d.ts +19 -19
  163. package/lib/types/utils/index.js +19 -19
  164. package/lib/websocket/SharedTypes.d.ts +2 -2
  165. package/lib/websocket/constants/index.js +2 -2
  166. package/lib/websocket/discord/heartbeater.d.ts +1 -0
  167. package/lib/websocket/discord/heartbeater.js +8 -0
  168. package/lib/websocket/discord/shard.d.ts +19 -10
  169. package/lib/websocket/discord/shard.js +254 -121
  170. package/lib/websocket/discord/sharder.d.ts +2 -2
  171. package/lib/websocket/discord/sharder.js +1 -1
  172. package/lib/websocket/discord/shared.d.ts +7 -2
  173. package/lib/websocket/discord/workermanager.d.ts +3 -1
  174. package/lib/websocket/discord/workermanager.js +31 -24
  175. package/package.json +2 -2
@@ -96,7 +96,11 @@ class GuildShorter extends base_1.BaseShorter {
96
96
  if ('code' in result && result.code === 110_000) {
97
97
  if (!wait)
98
98
  throw new error_1.SeyfertError('GUILD_SEARCH_INDEX_NOT_READY', {
99
- metadata: { guildId, retryAfter: result.retry_after },
99
+ metadata: {
100
+ guildId,
101
+ retryAfter: result.retry_after,
102
+ detail: `Guild search index for ${guildId} is not ready; retry after ${result.retry_after} seconds.`,
103
+ },
100
104
  });
101
105
  await (0, utils_1.delay)(result.retry_after * 1000);
102
106
  return this.searchMessages(guildId, query, wait);
@@ -14,10 +14,11 @@ class InteractionShorter extends base_1.BaseShorter {
14
14
  return this.client.proxy
15
15
  .interactions(id)(token)
16
16
  .callback.post({
17
+ auth: false,
17
18
  body: __1.BaseInteraction.transformBodyRequest({
18
19
  type: body.type,
19
20
  data,
20
- }, parsedFiles, this.client),
21
+ }, files, this.client),
21
22
  files: parsedFiles,
22
23
  query: { with_response: withResponse },
23
24
  });
@@ -40,7 +41,8 @@ class InteractionShorter extends base_1.BaseShorter {
40
41
  .webhooks(this.client.applicationId)(token)
41
42
  .messages(messageId)
42
43
  .patch({
43
- body: __1.BaseInteraction.transformBody(data, parsedFiles, this.client),
44
+ auth: false,
45
+ body: __1.BaseInteraction.transformBody(data, files, this.client),
44
46
  files: parsedFiles,
45
47
  });
46
48
  return transformers_1.Transformers.WebhookMessage(this.client, apiMessage, this.client.applicationId, token);
@@ -52,7 +54,7 @@ class InteractionShorter extends base_1.BaseShorter {
52
54
  return this.client.proxy
53
55
  .webhooks(this.client.applicationId)(token)
54
56
  .messages(messageId)
55
- .delete()
57
+ .delete({ auth: false })
56
58
  .then(() => this.client.components.deleteValue(messageId, 'messageDelete'));
57
59
  }
58
60
  deleteOriginal(token) {
@@ -63,7 +65,8 @@ class InteractionShorter extends base_1.BaseShorter {
63
65
  const apiMessage = (await this.client.proxy
64
66
  .webhooks(this.client.applicationId)(token)
65
67
  .post({
66
- body: __1.BaseInteraction.transformBody(body, parsedFiles, this.client),
68
+ auth: false,
69
+ body: __1.BaseInteraction.transformBody(body, files, this.client),
67
70
  files: parsedFiles,
68
71
  }));
69
72
  return transformers_1.Transformers.WebhookMessage(this.client, apiMessage, this.client.applicationId, token);
@@ -84,6 +84,7 @@ export declare class InvitesShorter extends BaseShorter {
84
84
  slug?: string | undefined;
85
85
  coverImage?: string | undefined;
86
86
  flags?: import("../../types").ApplicationFlags | undefined;
87
+ flagsNew?: string | undefined;
87
88
  approximateGuildCount?: number | undefined;
88
89
  approximateUserInstallCount?: number | undefined;
89
90
  redirectUris?: string[] | undefined;
@@ -239,6 +240,7 @@ export declare class InvitesShorter extends BaseShorter {
239
240
  slug?: string | undefined;
240
241
  coverImage?: string | undefined;
241
242
  flags?: import("../../types").ApplicationFlags | undefined;
243
+ flagsNew?: string | undefined;
242
244
  approximateGuildCount?: number | undefined;
243
245
  approximateUserInstallCount?: number | undefined;
244
246
  redirectUris?: string[] | undefined;
@@ -415,6 +417,7 @@ export declare class InvitesShorter extends BaseShorter {
415
417
  slug?: string | undefined;
416
418
  coverImage?: string | undefined;
417
419
  flags?: import("../../types").ApplicationFlags | undefined;
420
+ flagsNew?: string | undefined;
418
421
  approximateGuildCount?: number | undefined;
419
422
  approximateUserInstallCount?: number | undefined;
420
423
  redirectUris?: string[] | undefined;
@@ -575,6 +578,7 @@ export declare class InvitesShorter extends BaseShorter {
575
578
  slug?: string | undefined;
576
579
  coverImage?: string | undefined;
577
580
  flags?: import("../../types").ApplicationFlags | undefined;
581
+ flagsNew?: string | undefined;
578
582
  approximateGuildCount?: number | undefined;
579
583
  approximateUserInstallCount?: number | undefined;
580
584
  redirectUris?: string[] | undefined;
@@ -750,6 +754,7 @@ export declare class InvitesShorter extends BaseShorter {
750
754
  slug?: string | undefined;
751
755
  coverImage?: string | undefined;
752
756
  flags?: import("../../types").ApplicationFlags | undefined;
757
+ flagsNew?: string | undefined;
753
758
  approximateGuildCount?: number | undefined;
754
759
  approximateUserInstallCount?: number | undefined;
755
760
  redirectUris?: string[] | undefined;
@@ -4,6 +4,7 @@ exports.MemberShorter = void 0;
4
4
  const cache_1 = require("../../cache");
5
5
  const transformers_1 = require("../../client/transformers");
6
6
  const Permissions_1 = require("../../structures/extra/Permissions");
7
+ const GuildRole_1 = require("../../structures/GuildRole");
7
8
  const types_1 = require("../../types");
8
9
  const base_1 = require("./base");
9
10
  class MemberShorter extends base_1.BaseShorter {
@@ -182,7 +183,7 @@ class MemberShorter extends base_1.BaseShorter {
182
183
  }
183
184
  async sortRoles(guildId, memberId, force = false) {
184
185
  const roles = await this.listRoles(guildId, memberId, force);
185
- return roles.sort((a, b) => b.position - a.position);
186
+ return roles.sort((a, b) => GuildRole_1.GuildRole.comparePositions(b, a));
186
187
  }
187
188
  async permissions(guildId, memberId, force = false) {
188
189
  const roles = await this.listRoles(guildId, memberId, force);
@@ -9,7 +9,7 @@ const base_1 = require("./base");
9
9
  class MessageShorter extends base_1.BaseShorter {
10
10
  async write(channelId, { files, ...body }) {
11
11
  const parsedFiles = files ? await (0, builders_1.resolveFiles)(files) : undefined;
12
- const transformedBody = structures_1.MessagesMethods.transformMessageBody(body, parsedFiles, this.client);
12
+ const transformedBody = structures_1.MessagesMethods.transformMessageBody(body, files, this.client);
13
13
  return this.client.proxy
14
14
  .channels(channelId)
15
15
  .messages.post({
@@ -27,7 +27,7 @@ class MessageShorter extends base_1.BaseShorter {
27
27
  .channels(channelId)
28
28
  .messages(messageId)
29
29
  .patch({
30
- body: structures_1.MessagesMethods.transformMessageBody(body, parsedFiles, this.client),
30
+ body: structures_1.MessagesMethods.transformMessageBody(body, files, this.client),
31
31
  files: parsedFiles,
32
32
  })
33
33
  .then(async (message) => {
@@ -17,7 +17,7 @@ class ThreadShorter extends base_1.BaseShorter {
17
17
  if ('message' in body || 'files' in body) {
18
18
  const { message, files, ...rest } = body;
19
19
  const parsedFiles = files ? await (0, __1.resolveFiles)(files) : undefined;
20
- const transformedBody = structures_1.MessagesMethods.transformMessageBody(message ?? {}, parsedFiles, this.client);
20
+ const transformedBody = structures_1.MessagesMethods.transformMessageBody(message ?? {}, files, this.client);
21
21
  thread = await this.client.proxy.channels(channelId).threads.post({
22
22
  body: {
23
23
  ...rest,
@@ -69,10 +69,10 @@ class WebhookShorter extends base_1.BaseShorter {
69
69
  async writeMessage(webhookId, token, { body: data, ...payload }) {
70
70
  const { files, ...body } = data;
71
71
  const parsedFiles = files ? await (0, builders_1.resolveFiles)(files) : undefined;
72
- const transformedBody = structures_1.MessagesMethods.transformMessageBody(body, parsedFiles, this.client);
72
+ const transformedBody = structures_1.MessagesMethods.transformMessageBody(body, files, this.client);
73
73
  return this.client.proxy
74
74
  .webhooks(webhookId)(token)
75
- .post({ ...payload, files: parsedFiles, body: transformedBody })
75
+ .post({ ...payload, auth: false, files: parsedFiles, body: transformedBody })
76
76
  .then(m => (m?.id ? transformers_1.Transformers.WebhookMessage(this.client, m, webhookId, token) : null));
77
77
  }
78
78
  /**
@@ -86,7 +86,7 @@ class WebhookShorter extends base_1.BaseShorter {
86
86
  async editMessage(webhookId, token, { messageId, body: data, ...json }) {
87
87
  const { files, ...body } = data;
88
88
  const parsedFiles = files ? await (0, builders_1.resolveFiles)(files) : undefined;
89
- const transformedBody = structures_1.MessagesMethods.transformMessageBody(body, parsedFiles, this.client);
89
+ const transformedBody = structures_1.MessagesMethods.transformMessageBody(body, files, this.client);
90
90
  return this.client.proxy
91
91
  .webhooks(webhookId)(token)
92
92
  .messages(messageId)
@@ -51,7 +51,14 @@ export type MakeRequired<T, K extends keyof T = keyof T> = T & {
51
51
  export type PickRequired<T, K extends keyof T> = Omit<T, K> & {
52
52
  [P in K]: NonFalsy<T[P]>;
53
53
  };
54
+ export type MakePresent<T, K extends keyof T = keyof T> = T & {
55
+ [P in K]-?: NonNullish<T[P]>;
56
+ };
57
+ export type PickPresent<T, K extends keyof T> = Omit<T, K> & {
58
+ [P in K]-?: NonNullish<T[P]>;
59
+ };
54
60
  export type NonFalsy<T> = T extends false | 0 | '' | null | undefined | 0n ? never : T;
61
+ export type NonNullish<T> = T extends null | undefined ? never : T;
55
62
  export type CamelCase<S extends string> = S extends `${infer P1}_${infer P2}${infer P3}` ? `${Lowercase<P1>}${Uppercase<P2>}${CamelCase<P3>}` : Lowercase<S>;
56
63
  export type SnakeCase<S extends string> = S extends `${infer A}${infer Rest}` ? A extends Uppercase<A> ? `_${Lowercase<A>}${SnakeCase<Rest>}` : `${A}${SnakeCase<Rest>}` : Lowercase<S>;
57
64
  export type ObjectToLower<T> = T extends unknown[] ? ObjectToLower<T[0]>[] : Identify<{
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ComponentCommand = exports.InteractionCommandType = void 0;
4
4
  const types_1 = require("../types");
5
+ const customId_1 = require("./customId");
5
6
  exports.InteractionCommandType = {
6
7
  COMPONENT: 0,
7
8
  MODAL: 1,
@@ -12,8 +13,7 @@ class ComponentCommand {
12
13
  /** @internal */
13
14
  _filter(context) {
14
15
  if (this.customId) {
15
- const matches = typeof this.customId === 'string' ? this.customId === context.customId : context.customId.match(this.customId);
16
- if (!matches)
16
+ if (!(0, customId_1.matchesCustomId)(this.customId, context.customId))
17
17
  return false;
18
18
  }
19
19
  if (this.filter)
@@ -0,0 +1,3 @@
1
+ type ComponentCustomId = string | RegExp;
2
+ export declare function matchesCustomId(customId: ComponentCustomId, value: string): boolean;
3
+ export {};
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.matchesCustomId = matchesCustomId;
4
+ function matchesCustomId(customId, value) {
5
+ if (typeof customId === 'string')
6
+ return customId === value;
7
+ if (!customId.global && !customId.sticky)
8
+ return customId.test(value);
9
+ // String#search ignores and restores lastIndex for standard stateful regular expressions.
10
+ return value.search(customId) !== -1;
11
+ }
@@ -5,6 +5,7 @@ const collection_1 = require("../collection");
5
5
  const commands_1 = require("../commands");
6
6
  const common_1 = require("../common");
7
7
  const componentcommand_1 = require("./componentcommand");
8
+ const customId_1 = require("./customId");
8
9
  const modalcommand_1 = require("./modalcommand");
9
10
  class ComponentHandler extends common_1.BaseHandler {
10
11
  client;
@@ -19,11 +20,9 @@ class ComponentHandler extends common_1.BaseHandler {
19
20
  this.client = client;
20
21
  }
21
22
  createMatchCallback(match) {
22
- if (typeof match === 'string')
23
- return str => str === match;
24
23
  if (Array.isArray(match))
25
24
  return str => match.includes(str);
26
- return str => match.test(str);
25
+ return str => (0, customId_1.matchesCustomId)(match, str);
27
26
  }
28
27
  createComponentCollector(messageId, channelId, guildId, options = {}, components = []) {
29
28
  this.values.set(messageId, {
@@ -2,14 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ModalCommand = void 0;
4
4
  const componentcommand_1 = require("./componentcommand");
5
+ const customId_1 = require("./customId");
5
6
  class ModalCommand {
6
7
  type = componentcommand_1.InteractionCommandType.MODAL;
7
8
  customId;
8
9
  /** @internal */
9
10
  _filter(context) {
10
11
  if (this.customId) {
11
- const matches = typeof this.customId === 'string' ? this.customId === context.customId : context.customId.match(this.customId);
12
- if (!matches)
12
+ if (!(0, customId_1.matchesCustomId)(this.customId, context.customId))
13
13
  return false;
14
14
  }
15
15
  if (this.filter)
@@ -70,6 +70,7 @@ export declare const INVITE_CREATE: (_self: UsingClient, data: GatewayInviteCrea
70
70
  slug?: string | undefined;
71
71
  coverImage?: string | undefined;
72
72
  flags?: import("../../types").ApplicationFlags | undefined;
73
+ flagsNew?: string | undefined;
73
74
  approximateGuildCount?: number | undefined;
74
75
  approximateUserInstallCount?: number | undefined;
75
76
  redirectUris?: string[] | undefined;
@@ -81,6 +81,7 @@ export declare const PRESENCE_UPDATE: (self: UsingClient, data: GatewayPresenceU
81
81
  desktop?: import("../../types").PresenceUpdateReceiveStatus | undefined;
82
82
  mobile?: import("../../types").PresenceUpdateReceiveStatus | undefined;
83
83
  web?: import("../../types").PresenceUpdateReceiveStatus | undefined;
84
+ vr?: import("../../types").PresenceUpdateReceiveStatus | undefined;
84
85
  } | undefined;
85
86
  }, import("../..").ReturnCache<(Omit<import("../../types").GatewayPresenceUpdate, "user"> & {
86
87
  id: string;
@@ -30,6 +30,7 @@ export declare const THREAD_LIST_SYNC: (_self: UsingClient, data: GatewayThreadL
30
30
  appliedTags: string[];
31
31
  id: string;
32
32
  type: import("../../types").ThreadChannelType;
33
+ applicationId?: string | null | undefined;
33
34
  flags?: import("../../types").ChannelFlags | undefined;
34
35
  rateLimitPerUser?: number | undefined;
35
36
  lastMessageId?: string | null | undefined;
@@ -1,7 +1,7 @@
1
1
  import { BaseGuild } from './extra/BaseGuild';
2
2
  /**
3
3
  * Class for anonymous guilds.
4
- * @link https://discord.com/developers/docs/resources/guild#guild-resource
4
+ * @link https://docs.discord.com/developers/resources/guild#guild-resource
5
5
  */
6
6
  export declare class AnonymousGuild extends BaseGuild {
7
7
  }
@@ -4,7 +4,7 @@ exports.AnonymousGuild = void 0;
4
4
  const BaseGuild_1 = require("./extra/BaseGuild");
5
5
  /**
6
6
  * Class for anonymous guilds.
7
- * @link https://discord.com/developers/docs/resources/guild#guild-resource
7
+ * @link https://docs.discord.com/developers/resources/guild#guild-resource
8
8
  */
9
9
  class AnonymousGuild extends BaseGuild_1.BaseGuild {
10
10
  }
@@ -178,6 +178,7 @@ export declare class Guild<State extends StructStates = 'api'> extends Guild_bas
178
178
  slug?: string | undefined;
179
179
  coverImage?: string | undefined;
180
180
  flags?: import("../types").ApplicationFlags | undefined;
181
+ flagsNew?: string | undefined;
181
182
  approximateGuildCount?: number | undefined;
182
183
  approximateUserInstallCount?: number | undefined;
183
184
  redirectUris?: string[] | undefined;
@@ -338,6 +339,7 @@ export declare class Guild<State extends StructStates = 'api'> extends Guild_bas
338
339
  slug?: string | undefined;
339
340
  coverImage?: string | undefined;
340
341
  flags?: import("../types").ApplicationFlags | undefined;
342
+ flagsNew?: string | undefined;
341
343
  approximateGuildCount?: number | undefined;
342
344
  approximateUserInstallCount?: number | undefined;
343
345
  redirectUris?: string[] | undefined;
@@ -493,6 +495,7 @@ export declare class Guild<State extends StructStates = 'api'> extends Guild_bas
493
495
  slug?: string | undefined;
494
496
  coverImage?: string | undefined;
495
497
  flags?: import("../types").ApplicationFlags | undefined;
498
+ flagsNew?: string | undefined;
496
499
  approximateGuildCount?: number | undefined;
497
500
  approximateUserInstallCount?: number | undefined;
498
501
  redirectUris?: string[] | undefined;
@@ -64,7 +64,7 @@ export interface GuildMember extends ObjectToLower<Omit<APIGuildMember, 'user' |
64
64
  }
65
65
  /**
66
66
  * Represents a guild member
67
- * @link https://discord.com/developers/docs/resources/guild#guild-member-object
67
+ * @link https://docs.discord.com/developers/resources/guild#guild-member-object
68
68
  */
69
69
  export declare class GuildMember extends BaseGuildMember {
70
70
  /** the choosen guild id */
@@ -111,7 +111,7 @@ export interface InteractionGuildMember extends ObjectToLower<Omit<APIInteractio
111
111
  }
112
112
  /**
113
113
  * Represents a guild member
114
- * @link https://discord.com/developers/docs/resources/guild#guild-member-object
114
+ * @link https://docs.discord.com/developers/resources/guild#guild-member-object
115
115
  */
116
116
  export declare class InteractionGuildMember extends GuildMember {
117
117
  permissions: PermissionsBitField;
@@ -5,6 +5,7 @@ const DiscordBase_1 = require("./extra/DiscordBase");
5
5
  const transformers_1 = require("../client/transformers");
6
6
  const common_1 = require("../common");
7
7
  const Permissions_1 = require("./extra/Permissions");
8
+ const GuildRole_1 = require("./GuildRole");
8
9
  class BaseGuildMember extends DiscordBase_1.DiscordBase {
9
10
  guildId;
10
11
  _roles;
@@ -80,7 +81,7 @@ class BaseGuildMember extends DiscordBase_1.DiscordBase {
80
81
  add: (id) => this.client.members.addRole(this.guildId, this.id, id),
81
82
  remove: (id) => this.client.members.removeRole(this.guildId, this.id, id),
82
83
  permissions: (force = false) => this.roles.list(force).then(roles => new Permissions_1.PermissionsBitField(roles.map(x => BigInt(x.permissions.bits)))),
83
- sorted: (force = false) => this.roles.list(force).then(roles => roles.sort((a, b) => b.position - a.position)),
84
+ sorted: (force = false) => this.roles.list(force).then(roles => roles.sort((a, b) => GuildRole_1.GuildRole.comparePositions(b, a))),
84
85
  highest: (force = false) => this.roles.sorted(force).then(roles => roles[0]),
85
86
  };
86
87
  }
@@ -103,7 +104,7 @@ class BaseGuildMember extends DiscordBase_1.DiscordBase {
103
104
  exports.BaseGuildMember = BaseGuildMember;
104
105
  /**
105
106
  * Represents a guild member
106
- * @link https://discord.com/developers/docs/resources/guild#guild-member-object
107
+ * @link https://docs.discord.com/developers/resources/guild#guild-member-object
107
108
  */
108
109
  class GuildMember extends BaseGuildMember {
109
110
  guildId;
@@ -170,7 +171,24 @@ class GuildMember extends BaseGuildMember {
170
171
  return false;
171
172
  if (this.client.botId === ownerId)
172
173
  return true;
173
- return (await this.__me.roles.highest()).position > (await this.roles.highest(force)).position;
174
+ const highestFromCompleteRoles = async (member, forceRoles) => {
175
+ const roles = await member.roles.sorted(forceRoles);
176
+ const roleIds = new Set(roles.map(role => role.id));
177
+ if (!member.roles.keys.every(roleId => roleIds.has(roleId)))
178
+ return;
179
+ return roles.at(0);
180
+ };
181
+ const myHighest = await highestFromCompleteRoles(this.__me, force);
182
+ const theirHighest = await highestFromCompleteRoles(this, force);
183
+ if (myHighest && theirHighest)
184
+ return GuildRole_1.GuildRole.comparePositions(myHighest, theirHighest) > 0;
185
+ if (force)
186
+ return false;
187
+ const forcedMyHighest = await highestFromCompleteRoles(this.__me, true);
188
+ const forcedTheirHighest = await highestFromCompleteRoles(this, true);
189
+ if (!forcedMyHighest || !forcedTheirHighest)
190
+ return false;
191
+ return GuildRole_1.GuildRole.comparePositions(forcedMyHighest, forcedTheirHighest) > 0;
174
192
  }
175
193
  async bannable(force = false) {
176
194
  return (await this.manageable(force)) && (await this.__me.fetchPermissions(force)).has(['BanMembers']);
@@ -190,7 +208,7 @@ class UnavailableMember extends BaseGuildMember {
190
208
  exports.UnavailableMember = UnavailableMember;
191
209
  /**
192
210
  * Represents a guild member
193
- * @link https://discord.com/developers/docs/resources/guild#guild-member-object
211
+ * @link https://docs.discord.com/developers/resources/guild#guild-member-object
194
212
  */
195
213
  class InteractionGuildMember extends GuildMember {
196
214
  permissions;
@@ -3,7 +3,7 @@ import type { APIGuildPreview } from '../types';
3
3
  import { AnonymousGuild } from './AnonymousGuild';
4
4
  /**
5
5
  * Represent Discord Guild Preview Object
6
- * @link https://discord.com/developers/docs/resources/guild#guild-preview-object
6
+ * @link https://docs.discord.com/developers/resources/guild#guild-preview-object
7
7
  */
8
8
  export declare class GuildPreview extends AnonymousGuild {
9
9
  constructor(client: UsingClient, data: APIGuildPreview);
@@ -4,7 +4,7 @@ exports.GuildPreview = void 0;
4
4
  const AnonymousGuild_1 = require("./AnonymousGuild");
5
5
  /**
6
6
  * Represent Discord Guild Preview Object
7
- * @link https://discord.com/developers/docs/resources/guild#guild-preview-object
7
+ * @link https://docs.discord.com/developers/resources/guild#guild-preview-object
8
8
  */
9
9
  class GuildPreview extends AnonymousGuild_1.AnonymousGuild {
10
10
  constructor(client, data) {
@@ -11,6 +11,19 @@ export declare class GuildRole extends DiscordBase {
11
11
  readonly guildId: string;
12
12
  permissions: PermissionsBitField;
13
13
  constructor(client: UsingClient, data: APIRole, guildId: string);
14
+ /**
15
+ * Compares the hierarchy positions of two roles.
16
+ * Discord ranks the lower snowflake higher when roles share the same position.
17
+ * @returns A positive number when the first role is higher, a negative number when the second role is higher, or 0
18
+ * when both roles have the same position and ID.
19
+ */
20
+ static comparePositions(first: Pick<APIRole, 'id' | 'position'>, second: Pick<APIRole, 'id' | 'position'>): number;
21
+ /**
22
+ * Compares this role's hierarchy position with another role.
23
+ * @returns A positive number when this role is higher, a negative number when the other role is higher, or 0 when
24
+ * both roles have the same position and ID.
25
+ */
26
+ comparePositionTo(role: Pick<APIRole, 'id' | 'position'>): number;
14
27
  guild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'>>;
15
28
  guild(mode: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;
16
29
  fetch(force?: boolean): Promise<GuildRoleStructure>;
@@ -12,6 +12,27 @@ class GuildRole extends DiscordBase_1.DiscordBase {
12
12
  this.guildId = guildId;
13
13
  this.permissions = new Permissions_1.PermissionsBitField(BigInt(data.permissions));
14
14
  }
15
+ /**
16
+ * Compares the hierarchy positions of two roles.
17
+ * Discord ranks the lower snowflake higher when roles share the same position.
18
+ * @returns A positive number when the first role is higher, a negative number when the second role is higher, or 0
19
+ * when both roles have the same position and ID.
20
+ */
21
+ static comparePositions(first, second) {
22
+ if (first.position !== second.position)
23
+ return first.position - second.position;
24
+ if (first.id === second.id)
25
+ return 0;
26
+ return BigInt(first.id) < BigInt(second.id) ? 1 : -1;
27
+ }
28
+ /**
29
+ * Compares this role's hierarchy position with another role.
30
+ * @returns A positive number when this role is higher, a negative number when the other role is higher, or 0 when
31
+ * both roles have the same position and ID.
32
+ */
33
+ comparePositionTo(role) {
34
+ return GuildRole.comparePositions(this, role);
35
+ }
15
36
  guild(mode = 'flow') {
16
37
  switch (mode) {
17
38
  case 'cache':
@@ -17,7 +17,7 @@ class GuildTemplate extends Base_1.Base {
17
17
  }
18
18
  }
19
19
  fetch() {
20
- return this.client.templates.fetch(this.sourceGuildId);
20
+ return this.client.templates.fetch(this.code);
21
21
  }
22
22
  sync() {
23
23
  return this.client.templates.sync(this.sourceGuildId, this.code);
@@ -3,9 +3,9 @@ import { Attachment } from '../builders';
3
3
  import type { ReturnCache } from '../cache';
4
4
  import { type EntitlementStructure, type GuildRoleStructure, type GuildStructure, type InteractionGuildMemberStructure, type MessageStructure, type OptionResolverStructure, type UserStructure, type WebhookMessageStructure } from '../client/transformers';
5
5
  import type { UsingClient } from '../commands';
6
- import { type ComponentInteractionMessageUpdate, type InteractionCreateBodyRequest, type InteractionMessageUpdateBodyRequest, type MessageCreateBodyRequest, type MessageUpdateBodyRequest, type MessageWebhookCreateBodyRequest, type ModalCreateBodyRequest, type ModalCreateOptions, type ObjectToLower, type OmitInsert, type ToClass, type When } from '../common';
6
+ import { type ComponentInteractionMessageUpdate, type InteractionCreateBodyRequest, type InteractionMessageUpdateBodyRequest, type MessageCreateBodyRequest, type MessageUpdateBodyRequest, type MessageWebhookCreateBodyRequest, type ModalCreateBodyRequest, type ModalCreateOptions, type ObjectToLower, type OmitInsert, type ResolverProps, type ToClass, type When } from '../common';
7
7
  import { type APIApplicationCommandAutocompleteInteraction, type APIApplicationCommandInteraction, type APIBaseInteraction, type APIChatInputApplicationCommandInteraction, type APIChatInputApplicationCommandInteractionData, type APICommandAutocompleteInteractionResponseCallbackData, type APIEntryPointCommandInteraction, type APIInteraction, type APIInteractionResponse, type APIInteractionResponseChannelMessageWithSource, type APIInteractionResponseDeferredChannelMessageWithSource, type APIInteractionResponseDeferredMessageUpdate, type APIInteractionResponsePong, type APIInteractionResponseUpdateMessage, type APIMessageApplicationCommandInteraction, type APIMessageApplicationCommandInteractionData, type APIMessageButtonInteractionData, type APIMessageComponentInteraction, type APIMessageComponentSelectMenuInteraction, type APIMessageStringSelectInteractionData, type APIModalSubmission, type APIModalSubmitInteraction, type APIUserApplicationCommandInteraction, type APIUserApplicationCommandInteractionData, ApplicationCommandType, ComponentType, type GatewayInteractionCreateDispatchData, type InteractionCallbackData, type InteractionCallbackResourceActivity, InteractionResponseType, InteractionType, type MessageFlags, type ModalSubmitInsideLabelData, type RESTPostAPIInteractionCallbackJSONBody, type RESTPostAPIInteractionCallbackResult } from '../types';
8
- import { type AllChannels } from './';
8
+ import { type AllChannels, type ResolvedChannel } from './';
9
9
  import { DiscordBase } from './extra/DiscordBase';
10
10
  import { PermissionsBitField } from './extra/Permissions';
11
11
  export type ReplyInteractionBody = {
@@ -35,8 +35,8 @@ export declare class BaseInteraction<FromGuild extends boolean = boolean, Type e
35
35
  appPermissions: PermissionsBitField;
36
36
  entitlements: EntitlementStructure[];
37
37
  constructor(client: UsingClient, interaction: Type, __reply?: __InternalReplyFunction | undefined);
38
- static transformBodyRequest(body: ReplyInteractionBody, files: RawFile[] | undefined, self: UsingClient): APIInteractionResponse;
39
- static transformBody<T>(body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest | MessageUpdateBodyRequest | MessageCreateBodyRequest | MessageWebhookCreateBodyRequest, files: RawFile[] | undefined, self: UsingClient): T;
38
+ static transformBodyRequest(body: ReplyInteractionBody, files: ResolverProps['files'], self: UsingClient): APIInteractionResponse;
39
+ static transformBody<T>(body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest | MessageUpdateBodyRequest | MessageCreateBodyRequest | MessageWebhookCreateBodyRequest, files: ResolverProps['files'], self: UsingClient): T;
40
40
  private matchReplied;
41
41
  reply<WR extends boolean = false>(body: ReplyInteractionBody, withResponse?: WR): Promise<When<WR, WebhookMessageStructure, undefined>>;
42
42
  deferReply<WR extends boolean = false>(flags?: MessageFlags, withResponse?: WR): Promise<When<WR, WebhookMessageStructure, undefined>>;
@@ -145,7 +145,7 @@ export declare class StringSelectMenuInteraction<T extends any[] = string[]> ext
145
145
  }
146
146
  export declare class ChannelSelectMenuInteraction extends SelectMenuInteraction {
147
147
  protected __reply?: __InternalReplyFunction | undefined;
148
- channels: AllChannels[];
148
+ channels: ResolvedChannel[];
149
149
  channel: AllChannels;
150
150
  constructor(client: UsingClient, interaction: APIMessageComponentSelectMenuInteraction, __reply?: __InternalReplyFunction | undefined);
151
151
  isChannelSelectMenu(): this is ChannelSelectMenuInteraction;
@@ -235,8 +235,8 @@ export declare class ModalSubmitInteraction<FromGuild extends boolean = boolean>
235
235
  } | undefined;
236
236
  }[];
237
237
  getComponent(customId: string, type?: ComponentType[]): ObjectToLower<ModalSubmitInsideLabelData> | undefined;
238
- getChannels(customId: string, required: true): AllChannels[];
239
- getChannels(customId: string, required?: false): AllChannels[] | void;
238
+ getChannels(customId: string, required: true): ResolvedChannel[];
239
+ getChannels(customId: string, required?: false): ResolvedChannel[] | void;
240
240
  getRoles(customId: string, required: true): GuildRoleStructure[];
241
241
  getRoles(customId: string, required?: false): GuildRoleStructure[] | void;
242
242
  getUsers(customId: string, required: true): UserStructure[];