seyfert 4.5.0 → 5.0.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 (230) hide show
  1. package/lib/api/Routes/cdn.d.ts +2 -2
  2. package/lib/api/Routes/guilds.d.ts +2 -2
  3. package/lib/api/Routes/invites.d.ts +2 -2
  4. package/lib/api/api.d.ts +20 -8
  5. package/lib/api/api.js +198 -44
  6. package/lib/api/shared.d.ts +30 -1
  7. package/lib/api/utils/constants.d.ts +1 -1
  8. package/lib/api/utils/constants.js +1 -1
  9. package/lib/api/utils/utils.d.ts +2 -1
  10. package/lib/api/utils/utils.js +1 -1
  11. package/lib/builders/Attachment.d.ts +1 -1
  12. package/lib/builders/Attachment.js +30 -8
  13. package/lib/builders/MediaGallery.d.ts +2 -2
  14. package/lib/builders/MediaGallery.js +10 -0
  15. package/lib/builders/Modal.d.ts +18 -8
  16. package/lib/builders/Modal.js +36 -7
  17. package/lib/builders/Poll.js +18 -0
  18. package/lib/builders/RadioGroup.d.ts +4 -3
  19. package/lib/builders/RadioGroup.js +24 -3
  20. package/lib/builders/SelectMenu.d.ts +8 -6
  21. package/lib/builders/SelectMenu.js +24 -3
  22. package/lib/builders/types.d.ts +3 -2
  23. package/lib/cache/adapters/default.d.ts +1 -1
  24. package/lib/cache/adapters/default.js +23 -26
  25. package/lib/cache/adapters/limited.d.ts +1 -0
  26. package/lib/cache/adapters/limited.js +47 -33
  27. package/lib/cache/index.d.ts +19 -25
  28. package/lib/cache/index.js +58 -6
  29. package/lib/cache/resources/bans.d.ts +1 -1
  30. package/lib/cache/resources/bans.js +4 -4
  31. package/lib/cache/resources/channels.d.ts +1 -1
  32. package/lib/cache/resources/channels.js +4 -4
  33. package/lib/cache/resources/default/base.d.ts +1 -1
  34. package/lib/cache/resources/default/base.js +8 -8
  35. package/lib/cache/resources/default/guild-based.d.ts +5 -5
  36. package/lib/cache/resources/default/guild-based.js +29 -16
  37. package/lib/cache/resources/default/guild-related.d.ts +5 -5
  38. package/lib/cache/resources/default/guild-related.js +14 -14
  39. package/lib/cache/resources/emojis.d.ts +1 -1
  40. package/lib/cache/resources/emojis.js +4 -4
  41. package/lib/cache/resources/guilds.js +28 -15
  42. package/lib/cache/resources/members.d.ts +1 -1
  43. package/lib/cache/resources/members.js +6 -6
  44. package/lib/cache/resources/messages.d.ts +7 -2
  45. package/lib/cache/resources/messages.js +43 -20
  46. package/lib/cache/resources/overwrites.d.ts +1 -1
  47. package/lib/cache/resources/overwrites.js +5 -8
  48. package/lib/cache/resources/roles.d.ts +1 -1
  49. package/lib/cache/resources/roles.js +4 -4
  50. package/lib/cache/resources/stickers.d.ts +1 -1
  51. package/lib/cache/resources/stickers.js +4 -4
  52. package/lib/cache/resources/users.js +4 -4
  53. package/lib/cache/resources/voice-states.d.ts +1 -1
  54. package/lib/cache/resources/voice-states.js +4 -4
  55. package/lib/client/base.d.ts +83 -24
  56. package/lib/client/base.js +594 -39
  57. package/lib/client/client.d.ts +28 -3
  58. package/lib/client/client.js +33 -9
  59. package/lib/client/collectors.d.ts +9 -8
  60. package/lib/client/collectors.js +19 -52
  61. package/lib/client/httpclient.d.ts +3 -0
  62. package/lib/client/index.d.ts +3 -1
  63. package/lib/client/index.js +4 -0
  64. package/lib/client/intents.d.ts +3 -0
  65. package/lib/client/intents.js +9 -0
  66. package/lib/client/plugins/api.d.ts +4 -0
  67. package/lib/client/plugins/api.js +550 -0
  68. package/lib/client/plugins/errors.d.ts +25 -0
  69. package/lib/client/plugins/errors.js +79 -0
  70. package/lib/client/plugins/order.d.ts +10 -0
  71. package/lib/client/plugins/order.js +32 -0
  72. package/lib/client/plugins/registry.d.ts +273 -0
  73. package/lib/client/plugins/registry.js +868 -0
  74. package/lib/client/plugins/shared.d.ts +23 -0
  75. package/lib/client/plugins/shared.js +193 -0
  76. package/lib/client/plugins/types.d.ts +398 -0
  77. package/lib/client/plugins/types.js +8 -0
  78. package/lib/client/plugins.d.ts +78 -0
  79. package/lib/client/plugins.js +558 -0
  80. package/lib/client/transformers.d.ts +33 -33
  81. package/lib/client/workerclient.d.ts +10 -1
  82. package/lib/client/workerclient.js +27 -17
  83. package/lib/collection.d.ts +10 -8
  84. package/lib/collection.js +19 -25
  85. package/lib/commands/applications/chat.d.ts +20 -18
  86. package/lib/commands/applications/chat.js +39 -14
  87. package/lib/commands/applications/chatcontext.d.ts +23 -15
  88. package/lib/commands/applications/chatcontext.js +23 -2
  89. package/lib/commands/applications/entryPoint.d.ts +4 -3
  90. package/lib/commands/applications/entryPoint.js +1 -1
  91. package/lib/commands/applications/entrycontext.d.ts +7 -9
  92. package/lib/commands/applications/entrycontext.js +3 -1
  93. package/lib/commands/applications/menu.d.ts +4 -3
  94. package/lib/commands/applications/menucontext.d.ts +7 -9
  95. package/lib/commands/applications/menucontext.js +3 -1
  96. package/lib/commands/applications/options.d.ts +23 -23
  97. package/lib/commands/applications/shared.d.ts +39 -17
  98. package/lib/commands/decorators.d.ts +50 -38
  99. package/lib/commands/decorators.js +15 -5
  100. package/lib/commands/handle.d.ts +19 -8
  101. package/lib/commands/handle.js +224 -143
  102. package/lib/commands/handler.d.ts +21 -8
  103. package/lib/commands/handler.js +157 -69
  104. package/lib/commands/index.d.ts +1 -0
  105. package/lib/commands/optionresolver.d.ts +2 -2
  106. package/lib/common/it/colors.js +12 -2
  107. package/lib/common/it/error.d.ts +9 -0
  108. package/lib/common/it/error.js +8 -0
  109. package/lib/common/it/fake-promise.d.ts +4 -0
  110. package/lib/common/it/fake-promise.js +10 -0
  111. package/lib/common/it/formatter.d.ts +14 -11
  112. package/lib/common/it/formatter.js +4 -3
  113. package/lib/common/it/logger.d.ts +7 -1
  114. package/lib/common/it/logger.js +24 -6
  115. package/lib/common/it/utils.d.ts +6 -8
  116. package/lib/common/it/utils.js +44 -42
  117. package/lib/common/shorters/application.d.ts +3 -3
  118. package/lib/common/shorters/application.js +3 -2
  119. package/lib/common/shorters/bans.d.ts +8 -4
  120. package/lib/common/shorters/bans.js +13 -5
  121. package/lib/common/shorters/channels.d.ts +4 -4
  122. package/lib/common/shorters/channels.js +4 -4
  123. package/lib/common/shorters/emojis.js +1 -0
  124. package/lib/common/shorters/guilds.d.ts +8 -8
  125. package/lib/common/shorters/guilds.js +14 -31
  126. package/lib/common/shorters/interaction.d.ts +1 -1
  127. package/lib/common/shorters/invites.d.ts +201 -201
  128. package/lib/common/shorters/members.d.ts +7 -7
  129. package/lib/common/shorters/members.js +13 -14
  130. package/lib/common/shorters/messages.d.ts +2 -2
  131. package/lib/common/shorters/soundboard.d.ts +5 -5
  132. package/lib/common/shorters/users.d.ts +1 -1
  133. package/lib/common/shorters/webhook.d.ts +3 -2
  134. package/lib/common/shorters/webhook.js +0 -7
  135. package/lib/common/types/options.d.ts +4 -0
  136. package/lib/common/types/util.d.ts +8 -0
  137. package/lib/common/types/write.d.ts +2 -1
  138. package/lib/components/BaseSelectMenuComponent.d.ts +1 -1
  139. package/lib/components/BaseSelectMenuComponent.js +1 -1
  140. package/lib/components/ButtonComponent.d.ts +3 -3
  141. package/lib/components/ChannelSelectMenuComponent.d.ts +2 -2
  142. package/lib/components/File.d.ts +1 -1
  143. package/lib/components/MediaGallery.d.ts +1 -1
  144. package/lib/components/MentionableSelectMenuComponent.d.ts +1 -1
  145. package/lib/components/RoleSelectMenuComponent.d.ts +1 -1
  146. package/lib/components/Separator.d.ts +1 -1
  147. package/lib/components/StringSelectMenuComponent.d.ts +1 -1
  148. package/lib/components/TextInputComponent.d.ts +1 -1
  149. package/lib/components/Thumbnail.d.ts +1 -1
  150. package/lib/components/UserSelectMenuComponent.d.ts +1 -1
  151. package/lib/components/componentcommand.d.ts +8 -7
  152. package/lib/components/componentcontext.d.ts +24 -36
  153. package/lib/components/componentcontext.js +7 -17
  154. package/lib/components/handler.d.ts +17 -7
  155. package/lib/components/handler.js +108 -49
  156. package/lib/components/index.d.ts +1 -0
  157. package/lib/components/index.js +1 -0
  158. package/lib/components/interactioncontext.d.ts +45 -0
  159. package/lib/components/interactioncontext.js +93 -0
  160. package/lib/components/modalcommand.d.ts +5 -4
  161. package/lib/components/modalcontext.d.ts +39 -20
  162. package/lib/components/modalcontext.js +59 -6
  163. package/lib/events/event.d.ts +9 -3
  164. package/lib/events/handler.d.ts +51 -6
  165. package/lib/events/handler.js +165 -36
  166. package/lib/events/hooks/application_command.d.ts +1 -1
  167. package/lib/events/hooks/auto_moderation.d.ts +2 -2
  168. package/lib/events/hooks/guild.d.ts +150 -150
  169. package/lib/events/hooks/interactions.d.ts +1 -1
  170. package/lib/events/hooks/invite.d.ts +20 -20
  171. package/lib/events/hooks/message.d.ts +27 -27
  172. package/lib/events/hooks/presence.d.ts +11 -11
  173. package/lib/events/hooks/soundboard.d.ts +6 -6
  174. package/lib/events/hooks/stage.d.ts +2 -2
  175. package/lib/events/hooks/subscriptions.d.ts +3 -3
  176. package/lib/events/hooks/thread.d.ts +30 -30
  177. package/lib/events/hooks/voice.d.ts +3 -4
  178. package/lib/events/hooks/voice.js +2 -1
  179. package/lib/events/utils.d.ts +4 -0
  180. package/lib/events/utils.js +59 -0
  181. package/lib/index.d.ts +9 -4
  182. package/lib/index.js +13 -8
  183. package/lib/langs/handler.d.ts +14 -11
  184. package/lib/langs/handler.js +46 -9
  185. package/lib/langs/router.d.ts +10 -3
  186. package/lib/structures/Application.d.ts +1 -1
  187. package/lib/structures/Emoji.d.ts +3 -3
  188. package/lib/structures/Emoji.js +2 -2
  189. package/lib/structures/Guild.d.ts +154 -154
  190. package/lib/structures/GuildBan.d.ts +4 -4
  191. package/lib/structures/GuildBan.js +3 -3
  192. package/lib/structures/GuildMember.d.ts +7 -7
  193. package/lib/structures/GuildMember.js +28 -7
  194. package/lib/structures/GuildRole.d.ts +1 -1
  195. package/lib/structures/GuildRole.js +2 -2
  196. package/lib/structures/Interaction.d.ts +11 -9
  197. package/lib/structures/Interaction.js +33 -12
  198. package/lib/structures/Message.d.ts +21 -14
  199. package/lib/structures/Message.js +29 -14
  200. package/lib/structures/User.d.ts +1 -1
  201. package/lib/structures/VoiceState.d.ts +4 -0
  202. package/lib/structures/VoiceState.js +13 -1
  203. package/lib/structures/Webhook.d.ts +9 -1
  204. package/lib/structures/Webhook.js +4 -1
  205. package/lib/structures/channels.d.ts +148 -134
  206. package/lib/structures/channels.js +27 -26
  207. package/lib/structures/extra/BitField.d.ts +4 -4
  208. package/lib/structures/extra/BitField.js +20 -4
  209. package/lib/structures/extra/DiscordBase.js +1 -1
  210. package/lib/structures/extra/Permissions.d.ts +2 -4
  211. package/lib/structures/extra/Permissions.js +1 -17
  212. package/lib/types/payloads/_interactions/responses.d.ts +2 -2
  213. package/lib/types/payloads/components.d.ts +4 -4
  214. package/lib/websocket/SharedTypes.d.ts +4 -4
  215. package/lib/websocket/constants/index.d.ts +1 -1
  216. package/lib/websocket/constants/index.js +3 -2
  217. package/lib/websocket/discord/events/memberUpdate.js +2 -2
  218. package/lib/websocket/discord/heartbeater.d.ts +1 -0
  219. package/lib/websocket/discord/heartbeater.js +7 -0
  220. package/lib/websocket/discord/shard.d.ts +2 -2
  221. package/lib/websocket/discord/shard.js +15 -13
  222. package/lib/websocket/discord/sharder.d.ts +8 -7
  223. package/lib/websocket/discord/sharder.js +25 -5
  224. package/lib/websocket/discord/shared.d.ts +19 -6
  225. package/lib/websocket/discord/socket/custom.js +5 -0
  226. package/lib/websocket/discord/worker.d.ts +1 -0
  227. package/lib/websocket/discord/worker.js +2 -0
  228. package/lib/websocket/discord/workermanager.d.ts +25 -11
  229. package/lib/websocket/discord/workermanager.js +41 -10
  230. package/package.json +12 -16
@@ -10,8 +10,8 @@ class GuildBan extends DiscordBase_1.DiscordBase {
10
10
  super(client, { ...data, id });
11
11
  this.guildId = guildId;
12
12
  }
13
- create(body, reason) {
14
- return this.client.bans.create(this.guildId, this.id, body, reason);
13
+ create(options) {
14
+ return this.client.bans.create(this.guildId, this.id, options);
15
15
  }
16
16
  remove(reason) {
17
17
  return this.client.bans.remove(this.guildId, this.id, reason);
@@ -35,7 +35,7 @@ class GuildBan extends DiscordBase_1.DiscordBase {
35
35
  return {
36
36
  fetch: (userId, force = false) => client.bans.fetch(guildId, userId, force),
37
37
  list: (query, force = false) => client.bans.list(guildId, query, force),
38
- create: (memberId, body, reason) => client.bans.create(guildId, memberId, body, reason),
38
+ create: (memberId, options) => client.bans.create(guildId, memberId, options),
39
39
  remove: (memberId, reason) => client.bans.remove(guildId, memberId, reason),
40
40
  bulkCreate: (body, reason) => client.bans.bulkCreate(guildId, body, reason),
41
41
  };
@@ -3,8 +3,8 @@ export type GuildMemberData = APIGuildMember | Omit<APIGuildMember, 'user'> | Ga
3
3
  import type { GuildRoleStructure, ReturnCache } from '../';
4
4
  import { type DMChannelStructure, type GuildMemberStructure, type GuildStructure, type MessageStructure, type UserStructure, type VoiceStateStructure } from '../client/transformers';
5
5
  import type { UsingClient } from '../commands';
6
- import { type GuildMemberResolvable, type ImageOptions, type MessageCreateBodyRequest, type MethodContext, type ObjectToLower } from '../common';
7
- import type { APIGuildMember, APIInteractionDataResolvedGuildMember, APIUser, GatewayGuildMemberAddDispatchData, GatewayGuildMemberUpdateDispatchData, RESTGetAPIGuildMembersQuery, RESTGetAPIGuildMembersSearchQuery, RESTPatchAPIGuildMemberJSONBody, RESTPutAPIGuildBanJSONBody, RESTPutAPIGuildMemberJSONBody } from '../types';
6
+ import { type BanOptions, type GuildMemberResolvable, type ImageOptions, type MessageCreateBodyRequest, type MethodContext, type ObjectToLower } from '../common';
7
+ import type { APIGuildMember, APIInteractionDataResolvedGuildMember, APIUser, GatewayGuildMemberAddDispatchData, GatewayGuildMemberUpdateDispatchData, RESTGetAPIGuildMembersQuery, RESTGetAPIGuildMembersSearchQuery, RESTPatchAPIGuildMemberJSONBody, RESTPutAPIGuildMemberJSONBody } from '../types';
8
8
  import { PermissionsBitField } from './extra/Permissions';
9
9
  export interface BaseGuildMember extends DiscordBase, ObjectToLower<Omit<APIGuildMember, 'user' | 'roles'>> {
10
10
  }
@@ -20,7 +20,7 @@ export declare class BaseGuildMember extends DiscordBase {
20
20
  guild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'>>;
21
21
  guild(mode: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;
22
22
  fetch(force?: boolean): Promise<GuildMemberStructure>;
23
- ban(body?: RESTPutAPIGuildBanJSONBody, reason?: string): Promise<void>;
23
+ ban(options?: BanOptions): Promise<void>;
24
24
  kick(reason?: string): Promise<void>;
25
25
  edit(body: RESTPatchAPIGuildMemberJSONBody, reason?: string): Promise<GuildMemberStructure>;
26
26
  presence(): ReturnCache<(Omit<import("../types").GatewayPresenceUpdate, "user"> & {
@@ -36,21 +36,21 @@ export declare class BaseGuildMember extends DiscordBase {
36
36
  get hasTimeout(): false | number;
37
37
  private patch;
38
38
  get roles(): {
39
- keys: string[];
39
+ keys: readonly string[];
40
40
  list: (force?: boolean) => Promise<GuildRoleStructure[]>;
41
41
  add: (id: string) => Promise<undefined>;
42
42
  remove: (id: string) => Promise<undefined>;
43
43
  permissions: (force?: boolean) => Promise<PermissionsBitField>;
44
44
  sorted: (force?: boolean) => Promise<GuildRoleStructure[]>;
45
- highest: (force?: boolean) => Promise<GuildRoleStructure>;
45
+ highest: (force?: boolean) => Promise<GuildRoleStructure | undefined>;
46
46
  };
47
47
  static methods({ client, guildId }: MethodContext<{
48
48
  guildId: string;
49
49
  }>): {
50
50
  resolve: (resolve: GuildMemberResolvable) => Promise<GuildMemberStructure | undefined>;
51
- search: (query?: RESTGetAPIGuildMembersSearchQuery) => Promise<GuildMemberStructure[]>;
51
+ search: (query: RESTGetAPIGuildMembersSearchQuery) => Promise<GuildMemberStructure[]>;
52
52
  unban: (id: string, reason?: string) => Promise<undefined>;
53
- ban: (id: string, body?: RESTPutAPIGuildBanJSONBody, reason?: string) => Promise<void>;
53
+ ban: (id: string, options?: BanOptions) => Promise<void>;
54
54
  kick: (id: string, reason?: string) => Promise<void>;
55
55
  edit: (id: string, body: RESTPatchAPIGuildMemberJSONBody, reason?: string) => Promise<GuildMemberStructure>;
56
56
  add: (id: string, body: RESTPutAPIGuildMemberJSONBody) => Promise<GuildMemberStructure | undefined>;
@@ -31,8 +31,8 @@ class BaseGuildMember extends DiscordBase_1.DiscordBase {
31
31
  fetch(force = false) {
32
32
  return this.client.members.fetch(this.guildId, this.id, force);
33
33
  }
34
- ban(body, reason) {
35
- return this.client.members.ban(this.guildId, this.id, body, reason);
34
+ ban(options) {
35
+ return this.client.members.ban(this.guildId, this.id, options);
36
36
  }
37
37
  kick(reason) {
38
38
  return this.client.members.kick(this.guildId, this.id, reason);
@@ -81,7 +81,7 @@ class BaseGuildMember extends DiscordBase_1.DiscordBase {
81
81
  remove: (id) => this.client.members.removeRole(this.guildId, this.id, id),
82
82
  permissions: (force = false) => this.roles.list(force).then(roles => new Permissions_1.PermissionsBitField(roles.map(x => BigInt(x.permissions.bits)))),
83
83
  sorted: (force = false) => this.roles.list(force).then(roles => roles.sort((a, b) => b.position - a.position)),
84
- highest: (force = false) => this.roles.sorted(force).then(roles => roles[0]),
84
+ highest: (force = false) => this.roles.sorted(force).then(roles => roles.at(0)),
85
85
  };
86
86
  }
87
87
  static methods({ client, guildId }) {
@@ -89,7 +89,7 @@ class BaseGuildMember extends DiscordBase_1.DiscordBase {
89
89
  resolve: (resolve) => client.members.resolve(guildId, resolve),
90
90
  search: (query) => client.members.search(guildId, query),
91
91
  unban: (id, reason) => client.members.unban(guildId, id, reason),
92
- ban: (id, body, reason) => client.members.ban(guildId, id, body, reason),
92
+ ban: (id, options) => client.members.ban(guildId, id, options),
93
93
  kick: (id, reason) => client.members.kick(guildId, id, reason),
94
94
  edit: (id, body, reason) => client.members.edit(guildId, id, body, reason),
95
95
  add: (id, body) => client.members.add(guildId, id, body),
@@ -162,15 +162,36 @@ class GuildMember extends BaseGuildMember {
162
162
  return this.roles.permissions(force);
163
163
  }
164
164
  async manageable(force = false) {
165
- this.__me = await this.client.guilds.fetchSelf(this.guildId, force);
166
- const ownerId = (await this.client.guilds.fetch(this.guildId, force)).ownerId;
165
+ const [me, guild] = await Promise.all([
166
+ this.client.guilds.fetchSelf(this.guildId, force),
167
+ this.client.guilds.fetch(this.guildId, force),
168
+ ]);
169
+ this.__me = me;
170
+ const ownerId = guild.ownerId;
167
171
  if (this.user.id === ownerId)
168
172
  return false;
169
173
  if (this.user.id === this.client.botId)
170
174
  return false;
171
175
  if (this.client.botId === ownerId)
172
176
  return true;
173
- return (await this.__me.roles.highest()).position > (await this.roles.highest(force)).position;
177
+ const highestFromCompleteRoles = async (member, forceRoles) => {
178
+ const roles = await member.roles.sorted(forceRoles);
179
+ const roleIds = new Set(roles.map(role => role.id));
180
+ if (!member.roles.keys.every(roleId => roleIds.has(roleId)))
181
+ return;
182
+ return roles.at(0);
183
+ };
184
+ const myHighest = await highestFromCompleteRoles(me, force);
185
+ const theirHighest = await highestFromCompleteRoles(this, force);
186
+ if (myHighest && theirHighest)
187
+ return myHighest.position > theirHighest.position;
188
+ if (force)
189
+ return false;
190
+ const forcedMyHighest = await highestFromCompleteRoles(me, true);
191
+ const forcedTheirHighest = await highestFromCompleteRoles(this, true);
192
+ if (!forcedMyHighest || !forcedTheirHighest)
193
+ return false;
194
+ return forcedMyHighest.position > forcedTheirHighest.position;
174
195
  }
175
196
  async bannable(force = false) {
176
197
  return (await this.manageable(force)) && (await this.__me.fetchPermissions(force)).has(['BanMembers']);
@@ -14,7 +14,7 @@ export declare class GuildRole extends DiscordBase {
14
14
  guild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'>>;
15
15
  guild(mode: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;
16
16
  fetch(force?: boolean): Promise<GuildRoleStructure>;
17
- edit(body: RESTPatchAPIGuildRoleJSONBody): Promise<GuildRoleStructure>;
17
+ edit(body: RESTPatchAPIGuildRoleJSONBody, reason?: string): Promise<GuildRoleStructure>;
18
18
  delete(reason?: string): Promise<void>;
19
19
  toString(): `<@&${string}>`;
20
20
  static methods(ctx: MethodContext<{
@@ -24,8 +24,8 @@ class GuildRole extends DiscordBase_1.DiscordBase {
24
24
  fetch(force = false) {
25
25
  return this.client.roles.fetch(this.guildId, this.id, force);
26
26
  }
27
- edit(body) {
28
- return this.client.roles.edit(this.guildId, this.id, body);
27
+ edit(body, reason) {
28
+ return this.client.roles.edit(this.guildId, this.id, body, reason);
29
29
  }
30
30
  delete(reason) {
31
31
  return this.client.roles.delete(this.guildId, this.id, reason);
@@ -4,7 +4,7 @@ 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
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';
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';
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 } from '../types';
8
8
  import { type AllChannels } from './';
9
9
  import { DiscordBase } from './extra/DiscordBase';
10
10
  import { PermissionsBitField } from './extra/Permissions';
@@ -30,7 +30,8 @@ export declare class BaseInteraction<FromGuild extends boolean = boolean, Type e
30
30
  member: When<FromGuild, InteractionGuildMemberStructure, undefined>;
31
31
  channel?: AllChannels;
32
32
  message?: MessageStructure;
33
- replied?: Promise<boolean | RESTPostAPIInteractionCallbackResult | undefined> | boolean;
33
+ replied?: boolean;
34
+ private _repliedPromise?;
34
35
  deferred?: boolean;
35
36
  appPermissions: PermissionsBitField;
36
37
  entitlements: EntitlementStructure[];
@@ -38,6 +39,7 @@ export declare class BaseInteraction<FromGuild extends boolean = boolean, Type e
38
39
  static transformBodyRequest(body: ReplyInteractionBody, files: RawFile[] | undefined, self: UsingClient): APIInteractionResponse;
39
40
  static transformBody<T>(body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest | MessageUpdateBodyRequest | MessageCreateBodyRequest | MessageWebhookCreateBodyRequest, files: RawFile[] | undefined, self: UsingClient): T;
40
41
  private matchReplied;
42
+ protected hasRepliedOrAwaitPendingReply(): Promise<boolean>;
41
43
  reply<WR extends boolean = false>(body: ReplyInteractionBody, withResponse?: WR): Promise<When<WR, WebhookMessageStructure, undefined>>;
42
44
  deferReply<WR extends boolean = false>(flags?: MessageFlags, withResponse?: WR): Promise<When<WR, WebhookMessageStructure, undefined>>;
43
45
  isButton(): this is ButtonInteraction;
@@ -52,14 +54,14 @@ export declare class BaseInteraction<FromGuild extends boolean = boolean, Type e
52
54
  isAutocomplete(): this is AutocompleteInteraction;
53
55
  isModal(): this is ModalSubmitInteraction;
54
56
  isEntryPoint(): this is EntryPointInteraction;
55
- static from(client: UsingClient, gateway: GatewayInteractionCreateDispatchData, __reply?: __InternalReplyFunction): ModalSubmitInteraction<boolean> | ButtonInteraction | ChannelSelectMenuInteraction | RoleSelectMenuInteraction | MentionableSelectMenuInteraction | UserSelectMenuInteraction | StringSelectMenuInteraction<string[]> | ChatInputCommandInteraction<boolean> | UserCommandInteraction<boolean> | MessageCommandInteraction<boolean> | AutocompleteInteraction<boolean> | BaseInteraction<boolean, import("../types").APIPingInteraction> | undefined;
57
+ static from(client: UsingClient, gateway: GatewayInteractionCreateDispatchData, __reply?: __InternalReplyFunction): ModalSubmitInteraction<boolean> | ButtonInteraction | ChannelSelectMenuInteraction | RoleSelectMenuInteraction | MentionableSelectMenuInteraction | UserSelectMenuInteraction | StringSelectMenuInteraction<string[]> | ChatInputCommandInteraction<boolean> | UserCommandInteraction<boolean> | MessageCommandInteraction<boolean> | AutocompleteInteraction<boolean, string | number> | BaseInteraction<boolean, APIApplicationCommandInteraction>;
56
58
  fetchGuild(mode?: 'rest' | 'flow'): Promise<GuildStructure<'cached' | 'api'> | undefined>;
57
59
  fetchGuild(mode: 'cache'): ReturnCache<GuildStructure<'cached'> | undefined>;
58
60
  }
59
61
  export type AllInteractions = AutocompleteInteraction | ChatInputCommandInteraction | UserCommandInteraction | MessageCommandInteraction | ComponentInteraction | SelectMenuInteraction | ModalSubmitInteraction | EntryPointInteraction | BaseInteraction;
60
- export interface AutocompleteInteraction extends ObjectToLower<Omit<APIApplicationCommandAutocompleteInteraction, 'user' | 'member' | 'type' | 'data' | 'message' | 'channel' | 'app_permissions'>> {
62
+ export interface AutocompleteInteraction<FromGuild extends boolean = boolean, ValueType extends string | number = string | number> extends ObjectToLower<Omit<APIApplicationCommandAutocompleteInteraction, 'user' | 'member' | 'type' | 'data' | 'message' | 'channel' | 'app_permissions'>> {
61
63
  }
62
- export declare class AutocompleteInteraction<FromGuild extends boolean = boolean> extends BaseInteraction<FromGuild, APIApplicationCommandAutocompleteInteraction> {
64
+ export declare class AutocompleteInteraction<FromGuild extends boolean = boolean, ValueType extends string | number = string | number> extends BaseInteraction<FromGuild, APIApplicationCommandAutocompleteInteraction> {
63
65
  protected __reply?: __InternalReplyFunction | undefined;
64
66
  type: InteractionType.ApplicationCommandAutocomplete;
65
67
  data: ObjectToLower<APIApplicationCommandAutocompleteInteraction['data']>;
@@ -68,8 +70,8 @@ export declare class AutocompleteInteraction<FromGuild extends boolean = boolean
68
70
  channel: AllChannels;
69
71
  constructor(client: UsingClient, interaction: APIApplicationCommandAutocompleteInteraction, resolver?: OptionResolverStructure, __reply?: __InternalReplyFunction | undefined);
70
72
  getInput(): string;
71
- respond(choices: APICommandAutocompleteInteractionResponseCallbackData['choices']): Promise<undefined>;
72
- isAutocomplete(): this is AutocompleteInteraction;
73
+ respond(choices: APICommandAutocompleteInteractionResponseCallbackData<ValueType>['choices']): Promise<undefined>;
74
+ isAutocomplete(): this is AutocompleteInteraction<FromGuild, ValueType>;
73
75
  /** @intenal */
74
76
  reply(..._args: unknown[]): Promise<any>;
75
77
  }
@@ -97,7 +99,7 @@ export declare class ApplicationCommandInteraction<FromGuild extends boolean = b
97
99
  */
98
100
  export declare class EntryPointInteraction<FromGuild extends boolean = boolean> extends ApplicationCommandInteraction<FromGuild, APIEntryPointCommandInteraction> {
99
101
  channel: AllChannels;
100
- withReponse(data?: InteractionCreateBodyRequest): Promise<EntryPointWithResponseResult>;
102
+ withResponse(data?: InteractionCreateBodyRequest): Promise<EntryPointWithResponseResult>;
101
103
  isEntryPoint(): this is EntryPointInteraction;
102
104
  }
103
105
  export interface EntryPointWithResponseResult {
@@ -197,7 +199,7 @@ export declare class ModalSubmitInteraction<FromGuild extends boolean = boolean>
197
199
  data: ObjectToLower<APIModalSubmission>;
198
200
  channel: AllChannels;
199
201
  update<WR extends boolean = false>(data: ComponentInteractionMessageUpdate, withResponse?: WR): Promise<When<WR, WebhookMessageStructure, undefined>>;
200
- deferUpdate<WR extends boolean = false>(withResponse?: WR): Promise<When<WR, WebhookMessageStructure, undefined>>;
202
+ deferUpdate(): Promise<undefined>;
201
203
  get customId(): string;
202
204
  get components(): {
203
205
  type: ComponentType.Label;
@@ -24,6 +24,7 @@ class BaseInteraction extends DiscordBase_1.DiscordBase {
24
24
  channel;
25
25
  message;
26
26
  replied;
27
+ _repliedPromise;
27
28
  deferred;
28
29
  appPermissions;
29
30
  entitlements;
@@ -52,7 +53,7 @@ class BaseInteraction extends DiscordBase_1.DiscordBase {
52
53
  return body;
53
54
  case types_1.InteractionResponseType.ChannelMessageWithSource:
54
55
  case types_1.InteractionResponseType.UpdateMessage: {
55
- //@ts-ignore
56
+ //@ts-expect-error
56
57
  return {
57
58
  type: body.type,
58
59
  // @ts-expect-error
@@ -83,7 +84,7 @@ class BaseInteraction extends DiscordBase_1.DiscordBase {
83
84
  allowed_mentions: self.options?.allowedMentions,
84
85
  ...body,
85
86
  components: body.components?.map(x => (x instanceof builders_1.ActionRow ? x.toJSON() : x)),
86
- embeds: body?.embeds?.map(x => (x instanceof builders_1.Embed ? x.toJSON() : x)),
87
+ embeds: body?.embeds?.map(x => ('toJSON' in x ? x.toJSON() : x)),
87
88
  poll: poll ? (poll instanceof builders_1.PollBuilder ? poll.toJSON() : poll) : undefined,
88
89
  };
89
90
  if (Array.isArray(body.attachments)) {
@@ -117,20 +118,38 @@ class BaseInteraction extends DiscordBase_1.DiscordBase {
117
118
  //@ts-expect-error
118
119
  const data = body.data instanceof builders_1.Modal ? body.data : rest;
119
120
  const parsedFiles = files ? await (0, builders_1.resolveFiles)(files) : undefined;
120
- await (this.replied = this.__reply({
121
+ const repliedPromise = this.__reply({
121
122
  body: BaseInteraction.transformBodyRequest({ data, type: body.type }, parsedFiles, this.client),
122
123
  files: parsedFiles,
123
- }).then(() => (this.replied = true)));
124
+ }).then(() => {
125
+ this.replied = true;
126
+ this._repliedPromise = undefined;
127
+ });
128
+ this._repliedPromise = repliedPromise;
129
+ await repliedPromise;
124
130
  return;
125
131
  }
126
- const result = await (this.replied = this.client.interactions.reply(this.id, this.token, body, withResponse));
127
- this.replied = true;
132
+ const repliedPromise = this.client.interactions.reply(this.id, this.token, body, withResponse).then(result => {
133
+ this.replied = true;
134
+ this._repliedPromise = undefined;
135
+ return result;
136
+ });
137
+ this._repliedPromise = repliedPromise;
138
+ const result = await repliedPromise;
128
139
  return result?.resource?.message
129
140
  ? transformers_1.Transformers.WebhookMessage(this.client, result.resource.message, this.id, this.token)
130
141
  : undefined;
131
142
  }
143
+ async hasRepliedOrAwaitPendingReply() {
144
+ const repliedPromise = this._repliedPromise;
145
+ if (!this.replied && !repliedPromise)
146
+ return false;
147
+ if (repliedPromise)
148
+ await repliedPromise;
149
+ return true;
150
+ }
132
151
  async reply(body, withResponse) {
133
- if (this.replied) {
152
+ if (this.replied || this._repliedPromise) {
134
153
  throw new common_1.SeyfertError('INTERACTION_ALREADY_REPLIED', { metadata: { detail: 'Interaction already replied' } });
135
154
  }
136
155
  const result = await this.matchReplied(body, withResponse);
@@ -203,6 +222,8 @@ class BaseInteraction extends DiscordBase_1.DiscordBase {
203
222
  return new MessageCommandInteraction(client, gateway, __reply);
204
223
  case types_1.ApplicationCommandType.PrimaryEntryPoint:
205
224
  return new EntryPointInteraction(client, gateway, __reply);
225
+ default:
226
+ return new BaseInteraction(client, gateway, __reply);
206
227
  }
207
228
  case types_1.InteractionType.MessageComponent:
208
229
  switch (gateway.data.component_type) {
@@ -219,7 +240,7 @@ class BaseInteraction extends DiscordBase_1.DiscordBase {
219
240
  case types_1.ComponentType.StringSelect:
220
241
  return new StringSelectMenuInteraction(client, gateway, __reply);
221
242
  default:
222
- return;
243
+ return new BaseInteraction(client, gateway, __reply);
223
244
  }
224
245
  case types_1.InteractionType.ModalSubmit:
225
246
  return new ModalSubmitInteraction(client, gateway);
@@ -309,7 +330,7 @@ class Interaction extends BaseInteraction {
309
330
  return promise;
310
331
  }
311
332
  async editOrReply(body, fetchReply) {
312
- if (await this.replied) {
333
+ if (await this.hasRepliedOrAwaitPendingReply()) {
313
334
  const { content, embeds, allowed_mentions, components, files, attachments, poll, flags } = body;
314
335
  return this.editResponse({ content, embeds, allowed_mentions, components, files, attachments, poll, flags });
315
336
  }
@@ -343,7 +364,7 @@ exports.ApplicationCommandInteraction = ApplicationCommandInteraction;
343
364
  * Seyfert don't support activities, so this interaction is blank
344
365
  */
345
366
  class EntryPointInteraction extends ApplicationCommandInteraction {
346
- async withReponse(data) {
367
+ async withResponse(data) {
347
368
  let body = { type: types_1.InteractionResponseType.LaunchActivity };
348
369
  if (data) {
349
370
  let { files, ...rest } = data;
@@ -516,10 +537,10 @@ let ModalSubmitInteraction = class ModalSubmitInteraction extends BaseInteractio
516
537
  data,
517
538
  }, withResponse);
518
539
  }
519
- deferUpdate(withResponse) {
540
+ deferUpdate() {
520
541
  return this.reply({
521
542
  type: types_1.InteractionResponseType.DeferredMessageUpdate,
522
- }, withResponse);
543
+ });
523
544
  }
524
545
  get customId() {
525
546
  return this.data.customId;
@@ -1,14 +1,17 @@
1
- import { type AllChannels, Embed, type ReturnCache } from '..';
1
+ import type { ValidAnswerId } from '../api/Routes/channels';
2
2
  import type { ListenerOptions } from '../builders';
3
+ import { Embed } from '../builders/Embed';
4
+ import type { ReturnCache } from '../cache';
3
5
  import { type GuildMemberStructure, type GuildStructure, type MessageStructure, type PollStructure, type UserStructure, type WebhookMessageStructure, type WebhookStructure } from '../client/transformers';
4
6
  import type { UsingClient } from '../commands';
5
- import { type ObjectToLower } from '../common';
6
7
  import type { EmojiResolvable } from '../common/types/resolvables';
8
+ import type { ObjectToLower } from '../common/types/util';
7
9
  import type { MessageCreateBodyRequest, MessageUpdateBodyRequest } from '../common/types/write';
8
10
  import type { TopLevelComponents } from '../components';
9
11
  import type { APIChannelMention, APIEmbed, APIMessage, GatewayMessageCreateDispatchData } from '../types';
12
+ import type { AllChannels } from './channels';
10
13
  import { DiscordBase } from './extra/DiscordBase';
11
- import type { MessageWebhookMethodEditParams, MessageWebhookMethodWriteParams } from './Webhook';
14
+ import type { MessageWebhookMethodEditParams, MessageWebhookMethodWriteParams, MessageWebhookMethodWriteWaitParams } from './Webhook';
12
15
  export type MessageData = APIMessage | GatewayMessageCreateDispatchData;
13
16
  export interface BaseMessage extends DiscordBase, ObjectToLower<Omit<MessageData, 'timestamp' | 'author' | 'mentions' | 'components' | 'poll' | 'embeds'>> {
14
17
  timestamp?: number;
@@ -46,9 +49,12 @@ export declare class Message extends BaseMessage {
46
49
  write(body: MessageCreateBodyRequest): Promise<MessageStructure>;
47
50
  delete(reason?: string): Promise<void>;
48
51
  crosspost(reason?: string): Promise<MessageStructure>;
52
+ endPoll(): Promise<MessageStructure>;
53
+ getAnswerVoters(answerId: ValidAnswerId, checkAnswer?: boolean): Promise<UserStructure[]>;
49
54
  }
50
55
  export type EditMessageWebhook = Omit<MessageWebhookMethodEditParams, 'messageId'>['body'] & Pick<MessageWebhookMethodEditParams, 'query'>;
51
56
  export type WriteMessageWebhook = MessageWebhookMethodWriteParams['body'] & Pick<MessageWebhookMethodWriteParams, 'query'>;
57
+ export type WriteMessageWebhookWait = MessageWebhookMethodWriteWaitParams['body'] & Pick<MessageWebhookMethodWriteWaitParams, 'query'>;
52
58
  export declare class WebhookMessage extends BaseMessage {
53
59
  readonly webhookId: string;
54
60
  readonly webhookToken: string;
@@ -56,6 +62,7 @@ export declare class WebhookMessage extends BaseMessage {
56
62
  fetchWebhook(): Promise<WebhookStructure>;
57
63
  fetch(): Promise<WebhookMessageStructure>;
58
64
  edit(body: EditMessageWebhook): Promise<WebhookMessageStructure>;
65
+ write(body: WriteMessageWebhookWait): Promise<WebhookMessageStructure>;
59
66
  write(body: WriteMessageWebhook): Promise<WebhookMessageStructure | null>;
60
67
  delete(reason?: string): Promise<undefined>;
61
68
  }
@@ -63,7 +70,7 @@ export declare class InMessageEmbed {
63
70
  data: APIEmbed;
64
71
  constructor(data: APIEmbed);
65
72
  get title(): string | undefined;
66
- get type(): import("../types").EmbedType | undefined;
73
+ get type(): import("..").EmbedType | undefined;
67
74
  get description(): string | undefined;
68
75
  get url(): string | undefined;
69
76
  get timestamp(): string | undefined;
@@ -91,28 +98,28 @@ export declare class InMessageEmbed {
91
98
  height?: number | undefined;
92
99
  width?: number | undefined;
93
100
  } | undefined;
94
- get provider(): import("../types").APIEmbedProvider | undefined;
101
+ get provider(): import("..").APIEmbedProvider | undefined;
95
102
  get author(): {
96
103
  name: string;
97
104
  url?: string | undefined;
98
105
  iconUrl?: string | undefined;
99
106
  proxyIconUrl?: string | undefined;
100
107
  } | undefined;
101
- get fields(): import("../types").APIEmbedField[] | undefined;
108
+ get fields(): import("..").APIEmbedField[] | undefined;
102
109
  toBuilder(): Embed;
103
110
  toJSON(): {
104
111
  title?: string;
105
- type?: import("../types").EmbedType;
112
+ type?: import("..").EmbedType;
106
113
  description?: string;
107
114
  url?: string;
108
115
  timestamp?: string;
109
116
  color?: number;
110
- footer?: import("../types").APIEmbedFooter;
111
- image?: import("../types").APIEmbedImage;
112
- thumbnail?: import("../types").APIEmbedThumbnail;
113
- video?: import("../types").APIEmbedVideo;
114
- provider?: import("../types").APIEmbedProvider;
115
- author?: import("../types").APIEmbedAuthor;
116
- fields?: import("../types").APIEmbedField[];
117
+ footer?: import("..").APIEmbedFooter;
118
+ image?: import("..").APIEmbedImage;
119
+ thumbnail?: import("..").APIEmbedThumbnail;
120
+ video?: import("..").APIEmbedVideo;
121
+ provider?: import("..").APIEmbedProvider;
122
+ author?: import("..").APIEmbedAuthor;
123
+ fields?: import("..").APIEmbedField[];
117
124
  };
118
125
  }
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InMessageEmbed = exports.WebhookMessage = exports.Message = exports.BaseMessage = void 0;
4
- const __1 = require("..");
4
+ const Embed_1 = require("../builders/Embed");
5
5
  const transformers_1 = require("../client/transformers");
6
- const common_1 = require("../common");
6
+ const error_1 = require("../common/it/error");
7
+ const formatter_1 = require("../common/it/formatter");
8
+ const utils_1 = require("../common/it/utils");
9
+ const components_1 = require("../components");
7
10
  const DiscordBase_1 = require("./extra/DiscordBase");
8
11
  class BaseMessage extends DiscordBase_1.DiscordBase {
9
12
  embeds;
@@ -14,7 +17,7 @@ class BaseMessage extends DiscordBase_1.DiscordBase {
14
17
  channels: data.mention_channels ?? [],
15
18
  users: [],
16
19
  };
17
- this.components = data.components?.map(__1.componentFactory) ?? [];
20
+ this.components = data.components?.map(components_1.componentFactory) ?? [];
18
21
  this.embeds = data.embeds.map(embed => new InMessageEmbed(embed));
19
22
  this.patch(data);
20
23
  }
@@ -25,7 +28,7 @@ class BaseMessage extends DiscordBase_1.DiscordBase {
25
28
  return this.client.components.createComponentCollector(this.id, this.channelId, this.guildId, options);
26
29
  }
27
30
  get url() {
28
- return common_1.Formatter.messageLink(this.guildId ?? '@me', this.channelId, this.id);
31
+ return formatter_1.Formatter.messageLink(this.guildId ?? '@me', this.channelId, this.id);
29
32
  }
30
33
  guild(mode = 'flow') {
31
34
  if (!this.guildId)
@@ -62,10 +65,13 @@ class BaseMessage extends DiscordBase_1.DiscordBase {
62
65
  }
63
66
  if (data.mentions?.length) {
64
67
  this.mentions.users = this.guildId
65
- ? data.mentions.map(m => transformers_1.Transformers.GuildMember(this.client, {
66
- ...m.member,
67
- user: m,
68
- }, m, this.guildId))
68
+ ? data.mentions.map(m => {
69
+ const memberData = m.member;
70
+ if (memberData) {
71
+ return transformers_1.Transformers.GuildMember(this.client, { ...memberData, user: m }, m, this.guildId);
72
+ }
73
+ return transformers_1.Transformers.User(this.client, m);
74
+ })
69
75
  : data.mentions.map(u => transformers_1.Transformers.User(this.client, u));
70
76
  }
71
77
  if (data.poll) {
@@ -104,6 +110,15 @@ class Message extends BaseMessage {
104
110
  crosspost(reason) {
105
111
  return this.client.messages.crosspost(this.id, this.channelId, reason);
106
112
  }
113
+ endPoll() {
114
+ return this.client.messages.endPoll(this.channelId, this.id);
115
+ }
116
+ async getAnswerVoters(answerId, checkAnswer = false) {
117
+ if (checkAnswer && this.poll && !this.poll.answers.find(answer => answer.answerId === answerId)) {
118
+ throw new error_1.SeyfertError('INVALID_ANSWER_ID', { metadata: { detail: 'Invalid answer id' } });
119
+ }
120
+ return this.client.messages.getAnswerVoters(this.channelId, this.id, answerId);
121
+ }
107
122
  }
108
123
  exports.Message = Message;
109
124
  class WebhookMessage extends BaseMessage {
@@ -175,28 +190,28 @@ class InMessageEmbed {
175
190
  return this.data.color;
176
191
  }
177
192
  get footer() {
178
- return this.data.footer ? (0, common_1.toCamelCase)(this.data.footer) : undefined;
193
+ return this.data.footer ? (0, utils_1.toCamelCase)(this.data.footer) : undefined;
179
194
  }
180
195
  get image() {
181
- return this.data.image ? (0, common_1.toCamelCase)(this.data.image) : undefined;
196
+ return this.data.image ? (0, utils_1.toCamelCase)(this.data.image) : undefined;
182
197
  }
183
198
  get thumbnail() {
184
- return this.data.thumbnail ? (0, common_1.toCamelCase)(this.data.thumbnail) : undefined;
199
+ return this.data.thumbnail ? (0, utils_1.toCamelCase)(this.data.thumbnail) : undefined;
185
200
  }
186
201
  get video() {
187
- return this.data.video ? (0, common_1.toCamelCase)(this.data.video) : undefined;
202
+ return this.data.video ? (0, utils_1.toCamelCase)(this.data.video) : undefined;
188
203
  }
189
204
  get provider() {
190
205
  return this.data.provider;
191
206
  }
192
207
  get author() {
193
- return this.data.author ? (0, common_1.toCamelCase)(this.data.author) : undefined;
208
+ return this.data.author ? (0, utils_1.toCamelCase)(this.data.author) : undefined;
194
209
  }
195
210
  get fields() {
196
211
  return this.data.fields;
197
212
  }
198
213
  toBuilder() {
199
- return new __1.Embed(this.data);
214
+ return new Embed_1.Embed(this.data);
200
215
  }
201
216
  toJSON() {
202
217
  return { ...this.data };
@@ -21,7 +21,7 @@ export declare class User extends DiscordBase<APIUser> {
21
21
  avatarURL(options?: ImageOptions): string;
22
22
  avatarDecorationURL(options?: ImageOptions): string | undefined;
23
23
  bannerURL(options?: ImageOptions): string | undefined;
24
- presence(): import("..").ReturnCache<(Omit<import("../types").GatewayPresenceUpdate, "user"> & {
24
+ presence(): import("..").ReturnCache<(Omit<import("..").GatewayPresenceUpdate, "user"> & {
25
25
  id: string;
26
26
  user_id: string;
27
27
  } & {
@@ -10,6 +10,10 @@ export declare class VoiceState extends Base {
10
10
  protected withMember?: GuildMemberStructure;
11
11
  constructor(client: UsingClient, data: APIVoiceState);
12
12
  get isMuted(): boolean;
13
+ get isDeafened(): boolean;
14
+ get isCameraOn(): boolean;
15
+ get isStreaming(): boolean;
16
+ get isSuppressed(): boolean;
13
17
  member(force?: boolean): Promise<GuildMemberStructure>;
14
18
  user(force?: boolean): Promise<UserStructure>;
15
19
  channel(mode?: 'rest' | 'flow'): Promise<AllGuildVoiceChannels | undefined>;
@@ -15,6 +15,18 @@ class VoiceState extends Base_1.Base {
15
15
  get isMuted() {
16
16
  return this.mute || this.selfMute;
17
17
  }
18
+ get isDeafened() {
19
+ return this.deaf || this.selfDeaf;
20
+ }
21
+ get isCameraOn() {
22
+ return this.selfVideo;
23
+ }
24
+ get isStreaming() {
25
+ return this.selfStream ?? false;
26
+ }
27
+ get isSuppressed() {
28
+ return this.suppress;
29
+ }
18
30
  async member(force) {
19
31
  return (this.withMember = await this.client.members.fetch(this.guildId, this.userId, force));
20
32
  }
@@ -49,7 +61,7 @@ class VoiceState extends Base_1.Base {
49
61
  async requestSpeak(date = new Date()) {
50
62
  if (typeof date === 'string')
51
63
  date = new Date(date);
52
- if (Number.isNaN(date))
64
+ if (Number.isNaN(date.getTime()))
53
65
  return Promise.reject('Invalid date');
54
66
  date = date.toISOString();
55
67
  await this.client.voiceStates.requestSpeak(this.guildId, date);
@@ -72,7 +72,10 @@ export declare class Webhook extends DiscordBase {
72
72
  webhookToken: string;
73
73
  }>): {
74
74
  /** Writes a message through the webhook. */
75
- write: (payload: MessageWebhookMethodWriteParams) => Promise<WebhookMessageStructure | null>;
75
+ write: {
76
+ (payload: MessageWebhookMethodWriteWaitParams): Promise<WebhookMessageStructure>;
77
+ (payload: MessageWebhookMethodWriteParams): Promise<WebhookMessageStructure | null>;
78
+ };
76
79
  /** Edits a message sent through the webhook. */
77
80
  edit: (payload: MessageWebhookMethodEditParams) => Promise<WebhookMessageStructure>;
78
81
  /** Deletes a message sent through the webhook. */
@@ -103,5 +106,10 @@ export type MessageWebhookMethodEditParams = MessageWebhookPayload<MessageWebhoo
103
106
  export type MessageWebhookMethodWriteParams = MessageWebhookPayload<MessageWebhookCreateBodyRequest, {
104
107
  query?: RESTPostAPIWebhookWithTokenQuery;
105
108
  }>;
109
+ export type MessageWebhookMethodWriteWaitParams = MessageWebhookPayload<MessageWebhookCreateBodyRequest, {
110
+ query: RESTPostAPIWebhookWithTokenQuery & {
111
+ wait: true;
112
+ };
113
+ }>;
106
114
  export type MessageWebhookMethodDeleteParams = Omit<WebhookShorterMessageDeleteParams, 'token' | 'webhookId'>;
107
115
  export type MessageWebhookMethodFetchParams = Omit<WebhookShorterMessageFetchParams, 'token' | 'webhookId'>;
@@ -89,9 +89,12 @@ class Webhook extends DiscordBase_1.DiscordBase {
89
89
  * Static methods related to interacting with messages through webhooks.
90
90
  */
91
91
  static messages({ client, webhookId, webhookToken }) {
92
+ function write(payload) {
93
+ return client.webhooks.writeMessage(webhookId, webhookToken, payload);
94
+ }
92
95
  return {
93
96
  /** Writes a message through the webhook. */
94
- write: (payload) => client.webhooks.writeMessage(webhookId, webhookToken, payload),
97
+ write,
95
98
  /** Edits a message sent through the webhook. */
96
99
  edit: (payload) => client.webhooks.editMessage(webhookId, webhookToken, payload),
97
100
  /** Deletes a message sent through the webhook. */