seyfert 1.2.2 → 1.3.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 (162) hide show
  1. package/LICENSE +190 -190
  2. package/README.md +46 -46
  3. package/lib/api/Router.d.ts +9 -0
  4. package/lib/api/Router.js +16 -8
  5. package/lib/api/Routes/cdn.d.ts +26 -15
  6. package/lib/api/Routes/channels.d.ts +15 -1
  7. package/lib/api/api.d.ts +2 -3
  8. package/lib/api/api.js +4 -9
  9. package/lib/api/index.d.ts +0 -1
  10. package/lib/api/index.js +0 -1
  11. package/lib/api/utils/utils.d.ts +1 -1
  12. package/lib/api/utils/utils.js +2 -2
  13. package/lib/builders/Modal.d.ts +4 -1
  14. package/lib/builders/Modal.js +4 -1
  15. package/lib/builders/Poll.d.ts +16 -0
  16. package/lib/builders/Poll.js +48 -0
  17. package/lib/builders/index.d.ts +1 -0
  18. package/lib/builders/index.js +1 -0
  19. package/lib/cache/adapters/default.d.ts +1 -0
  20. package/lib/cache/adapters/default.js +4 -0
  21. package/lib/cache/adapters/index.d.ts +1 -0
  22. package/lib/cache/adapters/index.js +1 -0
  23. package/lib/cache/adapters/limited.d.ts +50 -0
  24. package/lib/cache/adapters/limited.js +188 -0
  25. package/lib/cache/adapters/redis.d.ts +2 -0
  26. package/lib/cache/adapters/redis.js +17 -0
  27. package/lib/cache/adapters/types.d.ts +1 -0
  28. package/lib/cache/adapters/workeradapter.d.ts +1 -0
  29. package/lib/cache/adapters/workeradapter.js +6 -9
  30. package/lib/cache/index.d.ts +8 -3
  31. package/lib/cache/index.js +41 -7
  32. package/lib/cache/resources/channels.d.ts +2 -1
  33. package/lib/cache/resources/default/base.d.ts +3 -3
  34. package/lib/cache/resources/default/base.js +8 -3
  35. package/lib/cache/resources/default/guild-based.d.ts +2 -1
  36. package/lib/cache/resources/default/guild-based.js +7 -3
  37. package/lib/cache/resources/default/guild-related.d.ts +2 -1
  38. package/lib/cache/resources/default/guild-related.js +7 -3
  39. package/lib/cache/resources/emojis.d.ts +2 -0
  40. package/lib/cache/resources/emojis.js +4 -0
  41. package/lib/cache/resources/guilds.d.ts +2 -0
  42. package/lib/cache/resources/guilds.js +4 -0
  43. package/lib/cache/resources/members.d.ts +2 -0
  44. package/lib/cache/resources/members.js +5 -1
  45. package/lib/cache/resources/messages.d.ts +15 -0
  46. package/lib/cache/resources/messages.js +53 -0
  47. package/lib/cache/resources/overwrites.d.ts +4 -0
  48. package/lib/cache/resources/overwrites.js +4 -0
  49. package/lib/cache/resources/presence.d.ts +1 -0
  50. package/lib/cache/resources/presence.js +4 -0
  51. package/lib/cache/resources/roles.d.ts +2 -0
  52. package/lib/cache/resources/roles.js +4 -0
  53. package/lib/cache/resources/stage-instances.d.ts +1 -0
  54. package/lib/cache/resources/stage-instances.js +5 -1
  55. package/lib/cache/resources/stickers.d.ts +2 -0
  56. package/lib/cache/resources/stickers.js +4 -0
  57. package/lib/cache/resources/threads.d.ts +2 -0
  58. package/lib/cache/resources/threads.js +4 -0
  59. package/lib/cache/resources/users.d.ts +2 -0
  60. package/lib/cache/resources/users.js +4 -0
  61. package/lib/cache/resources/voice-states.d.ts +2 -1
  62. package/lib/cache/resources/voice-states.js +8 -4
  63. package/lib/client/base.d.ts +26 -14
  64. package/lib/client/base.js +41 -13
  65. package/lib/client/client.d.ts +6 -5
  66. package/lib/client/client.js +13 -1
  67. package/lib/client/oninteractioncreate.js +2 -2
  68. package/lib/client/onmessagecreate.js +17 -14
  69. package/lib/client/workerclient.d.ts +3 -3
  70. package/lib/client/workerclient.js +23 -14
  71. package/lib/collection.d.ts +8 -3
  72. package/lib/collection.js +22 -4
  73. package/lib/commands/applications/chat.d.ts +17 -20
  74. package/lib/commands/applications/chat.js +6 -21
  75. package/lib/commands/applications/chatcontext.d.ts +1 -1
  76. package/lib/commands/applications/menucontext.d.ts +1 -1
  77. package/lib/commands/applications/shared.d.ts +4 -0
  78. package/lib/commands/applications/shared.js +6 -0
  79. package/lib/commands/decorators.d.ts +11 -1
  80. package/lib/commands/decorators.js +24 -0
  81. package/lib/commands/handler.d.ts +11 -7
  82. package/lib/commands/handler.js +43 -14
  83. package/lib/common/index.d.ts +2 -0
  84. package/lib/common/index.js +2 -0
  85. package/lib/common/it/utils.d.ts +0 -1
  86. package/lib/common/it/utils.js +0 -1
  87. package/lib/common/shorters/channels.d.ts +8 -3
  88. package/lib/common/shorters/channels.js +27 -12
  89. package/lib/common/shorters/guilds.d.ts +6 -5
  90. package/lib/common/shorters/guilds.js +22 -4
  91. package/lib/common/shorters/interaction.d.ts +13 -0
  92. package/lib/common/shorters/interaction.js +61 -0
  93. package/lib/common/shorters/messages.d.ts +6 -3
  94. package/lib/common/shorters/messages.js +33 -15
  95. package/lib/common/shorters/roles.d.ts +3 -3
  96. package/lib/common/shorters/roles.js +12 -17
  97. package/lib/common/shorters/templates.d.ts +7 -6
  98. package/lib/common/shorters/templates.js +28 -6
  99. package/lib/common/shorters/threads.d.ts +39 -0
  100. package/lib/common/shorters/threads.js +76 -0
  101. package/lib/common/shorters/webhook.d.ts +1 -1
  102. package/lib/common/shorters/webhook.js +8 -2
  103. package/lib/common/types/options.d.ts +2 -2
  104. package/lib/common/types/write.d.ts +8 -5
  105. package/lib/components/ButtonComponent.js +1 -1
  106. package/lib/components/componentcontext.d.ts +1 -1
  107. package/lib/components/handler.d.ts +6 -17
  108. package/lib/components/handler.js +7 -2
  109. package/lib/events/handler.d.ts +8 -14
  110. package/lib/events/handler.js +9 -4
  111. package/lib/events/hooks/guild.d.ts +1 -1
  112. package/lib/events/hooks/guild.js +2 -2
  113. package/lib/events/hooks/message.d.ts +26 -8
  114. package/lib/events/hooks/message.js +18 -7
  115. package/lib/langs/handler.d.ts +4 -8
  116. package/lib/langs/handler.js +7 -2
  117. package/lib/structures/AutoModerationRule.d.ts +6 -6
  118. package/lib/structures/Guild.d.ts +15 -13
  119. package/lib/structures/GuildEmoji.d.ts +2 -2
  120. package/lib/structures/GuildEmoji.js +1 -1
  121. package/lib/structures/GuildMember.js +1 -1
  122. package/lib/structures/GuildRole.d.ts +5 -5
  123. package/lib/structures/GuildTemplate.d.ts +10 -10
  124. package/lib/structures/Interaction.d.ts +3 -3
  125. package/lib/structures/Interaction.js +27 -48
  126. package/lib/structures/Message.d.ts +5 -3
  127. package/lib/structures/Message.js +5 -0
  128. package/lib/structures/Poll.d.ts +15 -0
  129. package/lib/structures/Poll.js +26 -0
  130. package/lib/structures/User.d.ts +2 -3
  131. package/lib/structures/User.js +9 -4
  132. package/lib/structures/Webhook.d.ts +2 -2
  133. package/lib/structures/Webhook.js +1 -1
  134. package/lib/structures/channels.d.ts +11 -3
  135. package/lib/structures/channels.js +16 -8
  136. package/lib/structures/extra/BaseGuild.js +3 -3
  137. package/lib/structures/extra/Permissions.d.ts +1 -0
  138. package/lib/structures/index.d.ts +1 -0
  139. package/lib/structures/index.js +1 -0
  140. package/lib/websocket/SharedTypes.d.ts +7 -2
  141. package/lib/websocket/discord/worker.d.ts +1 -1
  142. package/lib/websocket/discord/workermanager.js +3 -9
  143. package/lib/websocket/structures/timeout.js +9 -12
  144. package/package.json +8 -8
  145. package/lib/api/CDN.d.ts +0 -212
  146. package/lib/api/CDN.js +0 -228
  147. package/lib/client/http/adapters/bun.d.ts +0 -14
  148. package/lib/client/http/adapters/bun.js +0 -117
  149. package/lib/client/http/adapters/index.d.ts +0 -15
  150. package/lib/client/http/adapters/index.js +0 -27
  151. package/lib/client/http/adapters/uws.d.ts +0 -17
  152. package/lib/client/http/adapters/uws.js +0 -142
  153. package/lib/client/http/httpclient.d.ts +0 -13
  154. package/lib/client/http/httpclient.js +0 -48
  155. package/lib/common/shorters/overwrites.d.ts +0 -29
  156. package/lib/common/shorters/overwrites.js +0 -63
  157. package/lib/components/listener.d.ts +0 -11
  158. package/lib/components/listener.js +0 -17
  159. package/lib/structures/extra/BaseComponent.d.ts +0 -9
  160. package/lib/structures/extra/BaseComponent.js +0 -12
  161. package/lib/structures/extra/BaseSelectMenuComponent.d.ts +0 -9
  162. package/lib/structures/extra/BaseSelectMenuComponent.js +0 -13
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InteractionShorter = void 0;
4
+ const __1 = require("../..");
5
+ const base_1 = require("./base");
6
+ class InteractionShorter extends base_1.BaseShorter {
7
+ async reply(id, token, body) {
8
+ //@ts-expect-error
9
+ const { files, ...data } = body.data ?? {};
10
+ return this.client.proxy
11
+ .interactions(id)(token)
12
+ .callback.post({
13
+ body: __1.BaseInteraction.transformBodyRequest({
14
+ type: body.type,
15
+ data,
16
+ }),
17
+ files: files ? await (0, __1.resolveFiles)(files) : undefined,
18
+ });
19
+ }
20
+ fetchResponse(token, messageId) {
21
+ return this.client.webhooks.fetchMessage(this.client.applicationId, token, messageId);
22
+ }
23
+ fetchOriginal(token) {
24
+ return this.fetchResponse(token, '@original');
25
+ }
26
+ async editMessage(token, messageId, body) {
27
+ const { files, ...data } = body;
28
+ const apiMessage = await this.client.proxy
29
+ .webhooks(this.client.applicationId)(token)
30
+ .messages(messageId)
31
+ .patch({
32
+ body: __1.BaseInteraction.transformBody(data),
33
+ files: files ? await (0, __1.resolveFiles)(files) : undefined,
34
+ });
35
+ return new __1.WebhookMessage(this.client, apiMessage, this.client.applicationId, token);
36
+ }
37
+ editOriginal(token, body) {
38
+ return this.editMessage(token, '@original', body);
39
+ }
40
+ deleteResponse(interactionId, token, messageId) {
41
+ return this.client.proxy
42
+ .webhooks(this.client.applicationId)(token)
43
+ .messages(messageId)
44
+ .delete()
45
+ .then(() => this.client.components?.onMessageDelete(messageId === '@original' ? interactionId : messageId));
46
+ }
47
+ deleteOriginal(interactionId, token) {
48
+ return this.deleteResponse(interactionId, token, '@original');
49
+ }
50
+ async followup(token, { files, ...body }) {
51
+ files = files ? await (0, __1.resolveFiles)(files) : undefined;
52
+ const apiMessage = await this.client.proxy
53
+ .webhooks(this.client.applicationId)(token)
54
+ .post({
55
+ body: __1.BaseInteraction.transformBody(body),
56
+ files: files,
57
+ });
58
+ return new __1.WebhookMessage(this.client, apiMessage, this.client.applicationId, token);
59
+ }
60
+ }
61
+ exports.InteractionShorter = InteractionShorter;
@@ -1,15 +1,18 @@
1
1
  import type { RESTPostAPIChannelMessagesThreadsJSONBody } from 'discord-api-types/v10';
2
- import { Message, type ThreadChannel } from '../../structures';
2
+ import { Message, User } from '../../structures';
3
3
  import type { MessageCreateBodyRequest, MessageUpdateBodyRequest } from '../types/write';
4
4
  import { BaseShorter } from './base';
5
+ import type { ValidAnswerId } from '../../api/Routes/channels';
5
6
  export declare class MessageShorter extends BaseShorter {
6
7
  write(channelId: string, { files, ...body }: MessageCreateBodyRequest): Promise<Message>;
7
8
  edit(messageId: string, channelId: string, { files, ...body }: MessageUpdateBodyRequest): Promise<Message>;
8
9
  crosspost(messageId: string, channelId: string, reason?: string): Promise<Message>;
9
10
  delete(messageId: string, channelId: string, reason?: string): Promise<void>;
10
11
  fetch(messageId: string, channelId: string): Promise<Message>;
11
- purge(messages: string[], channelId: string, reason?: string): Promise<never>;
12
+ purge(messages: string[], channelId: string, reason?: string): Promise<void | undefined>;
12
13
  thread(channelId: string, messageId: string, options: RESTPostAPIChannelMessagesThreadsJSONBody & {
13
14
  reason?: string;
14
- }): Promise<ThreadChannel>;
15
+ }): Promise<import("../../structures").ThreadChannel>;
16
+ endPoll(channelId: string, messageId: string): Promise<Message>;
17
+ getAnswerVoters(channelId: string, messageId: string, answerId: ValidAnswerId): Promise<User[]>;
15
18
  }
@@ -1,12 +1,8 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.MessageShorter = void 0;
7
4
  const builders_1 = require("../../builders");
8
5
  const structures_1 = require("../../structures");
9
- const channels_1 = __importDefault(require("../../structures/channels"));
10
6
  const base_1 = require("./base");
11
7
  class MessageShorter extends base_1.BaseShorter {
12
8
  async write(channelId, { files, ...body }) {
@@ -18,7 +14,8 @@ class MessageShorter extends base_1.BaseShorter {
18
14
  body: transformedBody,
19
15
  files: parsedFiles,
20
16
  })
21
- .then(message => {
17
+ .then(async (message) => {
18
+ await this.client.cache.messages?.setIfNI('GuildMessages', message.id, message.channel_id, message);
22
19
  return new structures_1.Message(this.client, message);
23
20
  });
24
21
  }
@@ -31,7 +28,8 @@ class MessageShorter extends base_1.BaseShorter {
31
28
  body: structures_1.MessagesMethods.transformMessageBody(body),
32
29
  files: parsedFiles,
33
30
  })
34
- .then(message => {
31
+ .then(async (message) => {
32
+ await this.client.cache.messages?.setIfNI('GuildMessages', message.id, message.channel_id, message);
35
33
  return new structures_1.Message(this.client, message);
36
34
  });
37
35
  }
@@ -40,14 +38,18 @@ class MessageShorter extends base_1.BaseShorter {
40
38
  .channels(channelId)
41
39
  .messages(messageId)
42
40
  .crosspost.post({ reason })
43
- .then(m => new structures_1.Message(this.client, m));
41
+ .then(async (m) => {
42
+ await this.client.cache.messages?.setIfNI('GuildMessages', m.id, m.channel_id, m);
43
+ return new structures_1.Message(this.client, m);
44
+ });
44
45
  }
45
46
  delete(messageId, channelId, reason) {
46
47
  return this.client.proxy
47
48
  .channels(channelId)
48
49
  .messages(messageId)
49
50
  .delete({ reason })
50
- .then(() => {
51
+ .then(async () => {
52
+ await this.client.cache.messages?.removeIfNI('GuildMessages', messageId, channelId);
51
53
  void this.client.components?.onMessageDelete(messageId);
52
54
  });
53
55
  }
@@ -56,18 +58,34 @@ class MessageShorter extends base_1.BaseShorter {
56
58
  .channels(channelId)
57
59
  .messages(messageId)
58
60
  .get()
59
- .then(x => new structures_1.Message(this.client, x));
61
+ .then(async (x) => {
62
+ await this.client.cache.messages?.set(x.id, x.channel_id, x);
63
+ return new structures_1.Message(this.client, x);
64
+ });
60
65
  }
61
66
  purge(messages, channelId, reason) {
62
- return this.client.proxy.channels(channelId).messages['bulk-delete'].post({ body: { messages }, reason });
67
+ return this.client.proxy
68
+ .channels(channelId)
69
+ .messages['bulk-delete'].post({ body: { messages }, reason })
70
+ .then(() => this.client.cache.messages?.removeIfNI('GuildMessages', messages, channelId));
71
+ }
72
+ thread(channelId, messageId, options) {
73
+ return this.client.threads.fromMessage(channelId, messageId, options);
63
74
  }
64
- async thread(channelId, messageId, options) {
65
- const { reason, ...body } = options;
75
+ endPoll(channelId, messageId) {
66
76
  return this.client.proxy
67
77
  .channels(channelId)
68
- .messages(messageId)
69
- .threads.post({ body, reason })
70
- .then(thread => (0, channels_1.default)(thread, this.client));
78
+ .polls(messageId)
79
+ .expire.post()
80
+ .then(message => new structures_1.Message(this.client, message));
81
+ }
82
+ getAnswerVoters(channelId, messageId, answerId) {
83
+ return this.client.proxy
84
+ .channels(channelId)
85
+ .polls(messageId)
86
+ .answers(answerId)
87
+ .get()
88
+ .then(data => data.users.map(user => new structures_1.User(this.client, user)));
71
89
  }
72
90
  }
73
91
  exports.MessageShorter = MessageShorter;
@@ -9,7 +9,7 @@ export declare class RoleShorter extends BaseShorter {
9
9
  * @param reason The reason for creating the role.
10
10
  * @returns A Promise that resolves when the role is created.
11
11
  */
12
- create(guildId: string, body: RESTPostAPIGuildRoleJSONBody, reason?: string): Promise<any>;
12
+ create(guildId: string, body: RESTPostAPIGuildRoleJSONBody, reason?: string): Promise<GuildRole>;
13
13
  /**
14
14
  * Retrieves a list of roles in the guild.
15
15
  * @param guildId The ID of the guild.
@@ -25,7 +25,7 @@ export declare class RoleShorter extends BaseShorter {
25
25
  * @param reason The reason for editing the role.
26
26
  * @returns A Promise that resolves when the role is edited.
27
27
  */
28
- edit(guildId: string, roleId: string, body: RESTPatchAPIGuildRoleJSONBody, reason?: string): Promise<any>;
28
+ edit(guildId: string, roleId: string, body: RESTPatchAPIGuildRoleJSONBody, reason?: string): Promise<GuildRole>;
29
29
  /**
30
30
  * Deletes a role from the guild.
31
31
  * @param guildId The ID of the guild.
@@ -33,7 +33,7 @@ export declare class RoleShorter extends BaseShorter {
33
33
  * @param reason The reason for deleting the role.
34
34
  * @returns A Promise that resolves when the role is deleted.
35
35
  */
36
- delete(guildId: string, roleId: string, reason?: string): Promise<void | undefined>;
36
+ delete(guildId: string, roleId: string, reason?: string): Promise<GuildRole>;
37
37
  /**
38
38
  * Edits the positions of roles in the guild.
39
39
  * @param guildId The ID of the guild.
@@ -11,11 +11,10 @@ class RoleShorter extends base_1.BaseShorter {
11
11
  * @param reason The reason for creating the role.
12
12
  * @returns A Promise that resolves when the role is created.
13
13
  */
14
- create(guildId, body, reason) {
15
- return this.client.proxy
16
- .guilds(guildId)
17
- .roles.post({ body, reason })
18
- .then(res => this.client.cache.roles?.setIfNI('Guilds', res.id, guildId, res));
14
+ async create(guildId, body, reason) {
15
+ const res = await this.client.proxy.guilds(guildId).roles.post({ body, reason });
16
+ await this.client.cache.roles?.setIfNI('Guilds', res.id, guildId, res);
17
+ return new structures_1.GuildRole(this.client, res, guildId);
19
18
  }
20
19
  /**
21
20
  * Retrieves a list of roles in the guild.
@@ -43,12 +42,10 @@ class RoleShorter extends base_1.BaseShorter {
43
42
  * @param reason The reason for editing the role.
44
43
  * @returns A Promise that resolves when the role is edited.
45
44
  */
46
- edit(guildId, roleId, body, reason) {
47
- return this.client.proxy
48
- .guilds(guildId)
49
- .roles(roleId)
50
- .patch({ body, reason })
51
- .then(res => this.client.cache.roles?.setIfNI('Guilds', roleId, guildId, res));
45
+ async edit(guildId, roleId, body, reason) {
46
+ const res = await this.client.proxy.guilds(guildId).roles(roleId).patch({ body, reason });
47
+ await this.client.cache.roles?.setIfNI('Guilds', roleId, guildId, res);
48
+ return new structures_1.GuildRole(this.client, res, guildId);
52
49
  }
53
50
  /**
54
51
  * Deletes a role from the guild.
@@ -57,12 +54,10 @@ class RoleShorter extends base_1.BaseShorter {
57
54
  * @param reason The reason for deleting the role.
58
55
  * @returns A Promise that resolves when the role is deleted.
59
56
  */
60
- delete(guildId, roleId, reason) {
61
- return this.client.proxy
62
- .guilds(guildId)
63
- .roles(roleId)
64
- .delete({ reason })
65
- .then(() => this.client.cache.roles?.removeIfNI('Guilds', roleId, guildId));
57
+ async delete(guildId, roleId, reason) {
58
+ const res = await this.client.proxy.guilds(guildId).roles(roleId).delete({ reason });
59
+ this.client.cache.roles?.removeIfNI('Guilds', roleId, guildId);
60
+ return new structures_1.GuildRole(this.client, res, guildId);
66
61
  }
67
62
  /**
68
63
  * Edits the positions of roles in the guild.
@@ -1,10 +1,11 @@
1
1
  import type { RESTPatchAPIGuildTemplateJSONBody, RESTPostAPIGuildTemplatesJSONBody } from 'discord-api-types/v10';
2
2
  import { BaseShorter } from './base';
3
+ import { GuildTemplate } from '../..';
3
4
  export declare class TemplateShorter extends BaseShorter {
4
- fetch(code: string): Promise<import("discord-api-types/v10").APITemplate>;
5
- list(guildId: string): Promise<import("discord-api-types/v10").RESTGetAPIGuildTemplatesResult>;
6
- create(guildId: string, body: RESTPostAPIGuildTemplatesJSONBody): Promise<import("discord-api-types/v10").APITemplate>;
7
- sync(guildId: string, code: string): Promise<import("discord-api-types/v10").APITemplate>;
8
- edit(guildId: string, code: string, body: RESTPatchAPIGuildTemplateJSONBody): Promise<import("discord-api-types/v10").APITemplate>;
9
- delete(guildId: string, code: string): Promise<import("discord-api-types/v10").APITemplate>;
5
+ fetch(code: string): Promise<GuildTemplate>;
6
+ list(guildId: string): Promise<GuildTemplate[]>;
7
+ create(guildId: string, body: RESTPostAPIGuildTemplatesJSONBody): Promise<GuildTemplate>;
8
+ sync(guildId: string, code: string): Promise<GuildTemplate>;
9
+ edit(guildId: string, code: string, body: RESTPatchAPIGuildTemplateJSONBody): Promise<GuildTemplate>;
10
+ delete(guildId: string, code: string): Promise<GuildTemplate>;
10
11
  }
@@ -2,24 +2,46 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TemplateShorter = void 0;
4
4
  const base_1 = require("./base");
5
+ const __1 = require("../..");
5
6
  class TemplateShorter extends base_1.BaseShorter {
6
7
  fetch(code) {
7
- return this.client.proxy.guilds.templates(code).get();
8
+ return this.client.proxy.guilds
9
+ .templates(code)
10
+ .get()
11
+ .then(template => new __1.GuildTemplate(this.client, template));
8
12
  }
9
13
  list(guildId) {
10
- return this.client.proxy.guilds(guildId).templates.get();
14
+ return this.client.proxy
15
+ .guilds(guildId)
16
+ .templates.get()
17
+ .then(list => list.map(template => new __1.GuildTemplate(this.client, template)));
11
18
  }
12
19
  create(guildId, body) {
13
- return this.client.proxy.guilds(guildId).templates.post({ body });
20
+ return this.client.proxy
21
+ .guilds(guildId)
22
+ .templates.post({ body })
23
+ .then(template => new __1.GuildTemplate(this.client, template));
14
24
  }
15
25
  sync(guildId, code) {
16
- return this.client.proxy.guilds(guildId).templates(code).put({});
26
+ return this.client.proxy
27
+ .guilds(guildId)
28
+ .templates(code)
29
+ .put({})
30
+ .then(template => new __1.GuildTemplate(this.client, template));
17
31
  }
18
32
  edit(guildId, code, body) {
19
- return this.client.proxy.guilds(guildId).templates(code).patch({ body });
33
+ return this.client.proxy
34
+ .guilds(guildId)
35
+ .templates(code)
36
+ .patch({ body })
37
+ .then(template => new __1.GuildTemplate(this.client, template));
20
38
  }
21
39
  delete(guildId, code) {
22
- return this.client.proxy.guilds(guildId).templates(code).delete();
40
+ return this.client.proxy
41
+ .guilds(guildId)
42
+ .templates(code)
43
+ .delete()
44
+ .then(template => new __1.GuildTemplate(this.client, template));
23
45
  }
24
46
  }
25
47
  exports.TemplateShorter = TemplateShorter;
@@ -0,0 +1,39 @@
1
+ import type { APIThreadMember, RESTGetAPIChannelThreadMembersQuery, RESTGetAPIChannelThreadsArchivedQuery, RESTPatchAPIChannelJSONBody, RESTPostAPIChannelMessagesThreadsJSONBody, RESTPostAPIChannelThreadsJSONBody, RESTPostAPIGuildForumThreadsJSONBody } from 'discord-api-types/v10';
2
+ import type { ThreadChannel } from '../../structures';
3
+ import { BaseShorter } from './base';
4
+ import type { MakeRequired, When } from '../types/util';
5
+ export declare class ThreadShorter extends BaseShorter {
6
+ /**
7
+ * Creates a new thread in the channel (only guild based channels).
8
+ * @param channelId The ID of the parent channel.
9
+ * @param reason The reason for unpinning the message.
10
+ * @returns A promise that resolves when the thread is succesfully created.
11
+ */
12
+ create(channelId: string, body: RESTPostAPIChannelThreadsJSONBody | RESTPostAPIGuildForumThreadsJSONBody, reason?: string): Promise<ThreadChannel>;
13
+ fromMessage(channelId: string, messageId: string, options: RESTPostAPIChannelMessagesThreadsJSONBody & {
14
+ reason?: string;
15
+ }): Promise<ThreadChannel>;
16
+ join(threadId: string): Promise<never>;
17
+ leave(threadId: string): Promise<never>;
18
+ lock(threadId: string, locked?: boolean, reason?: string): Promise<ThreadChannel>;
19
+ edit(threadId: string, body: RESTPatchAPIChannelJSONBody, reason?: string): Promise<import("../../structures").AllChannels>;
20
+ removeMember(threadId: string, memberId: string): Promise<never>;
21
+ fetchMember<WithMember extends boolean = false>(threadId: string, memberId: string, with_member: WithMember): Promise<When<WithMember, Required<APIThreadMember>, GetAPIChannelThreadMemberResult>>;
22
+ addMember(threadId: string, memberId: string): Promise<never>;
23
+ listMembers<T extends RESTGetAPIChannelThreadMembersQuery = RESTGetAPIChannelThreadMembersQuery>(threadId: string, query?: T): Promise<InferWithMemberOnList<T>>;
24
+ listArchivedThreads(channelId: string, type: 'public' | 'private', query?: RESTGetAPIChannelThreadsArchivedQuery): Promise<{
25
+ threads: ThreadChannel[];
26
+ members: GetAPIChannelThreadMemberResult[];
27
+ hasMore: boolean;
28
+ }>;
29
+ listJoinedArchivedPrivate(channelId: string, query?: RESTGetAPIChannelThreadsArchivedQuery): Promise<{
30
+ threads: ThreadChannel[];
31
+ members: GetAPIChannelThreadMemberResult[];
32
+ hasMore: boolean;
33
+ }>;
34
+ }
35
+ export type GetAPIChannelThreadMemberResult = MakeRequired<APIThreadMember, 'id' | 'user_id'>;
36
+ type InferWithMemberOnList<T extends RESTGetAPIChannelThreadMembersQuery> = T extends {
37
+ with_member: infer B;
38
+ } ? B extends true ? Required<APIThreadMember>[] : GetAPIChannelThreadMemberResult[] : GetAPIChannelThreadMemberResult[];
39
+ export {};
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ThreadShorter = void 0;
7
+ const channels_1 = __importDefault(require("../../structures/channels"));
8
+ const base_1 = require("./base");
9
+ class ThreadShorter extends base_1.BaseShorter {
10
+ /**
11
+ * Creates a new thread in the channel (only guild based channels).
12
+ * @param channelId The ID of the parent channel.
13
+ * @param reason The reason for unpinning the message.
14
+ * @returns A promise that resolves when the thread is succesfully created.
15
+ */
16
+ async create(channelId, body, reason) {
17
+ return (this.client.proxy
18
+ .channels(channelId)
19
+ .threads.post({ body, reason })
20
+ // When testing this, discord returns the thread object, but in discord api types it does not.
21
+ .then(thread => (0, channels_1.default)(thread, this.client)));
22
+ }
23
+ async fromMessage(channelId, messageId, options) {
24
+ const { reason, ...body } = options;
25
+ return this.client.proxy
26
+ .channels(channelId)
27
+ .messages(messageId)
28
+ .threads.post({ body, reason })
29
+ .then(thread => (0, channels_1.default)(thread, this.client));
30
+ }
31
+ async join(threadId) {
32
+ return this.client.proxy.channels(threadId)['thread-members']('@me').put();
33
+ }
34
+ async leave(threadId) {
35
+ return this.client.proxy.channels(threadId)['thread-members']('@me').delete();
36
+ }
37
+ async lock(threadId, locked = true, reason) {
38
+ return this.edit(threadId, { locked }, reason).then(x => (0, channels_1.default)(x, this.client));
39
+ }
40
+ async edit(threadId, body, reason) {
41
+ return this.client.channels.edit(threadId, body, { reason });
42
+ }
43
+ async removeMember(threadId, memberId) {
44
+ return this.client.proxy.channels(threadId)['thread-members'](memberId).delete();
45
+ }
46
+ async fetchMember(threadId, memberId, with_member) {
47
+ return this.client.proxy.channels(threadId)['thread-members'](memberId).get({
48
+ query: {
49
+ with_member,
50
+ },
51
+ });
52
+ }
53
+ async addMember(threadId, memberId) {
54
+ return this.client.proxy.channels(threadId)['thread-members'](memberId).put();
55
+ }
56
+ async listMembers(threadId, query) {
57
+ return this.client.proxy.channels(threadId)['thread-members'].get({ query });
58
+ }
59
+ async listArchivedThreads(channelId, type, query) {
60
+ const data = await this.client.proxy.channels(channelId).threads.archived[type].get({ query });
61
+ return {
62
+ threads: data.threads.map(thread => (0, channels_1.default)(thread, this.client)),
63
+ members: data.members,
64
+ hasMore: data.has_more,
65
+ };
66
+ }
67
+ async listJoinedArchivedPrivate(channelId, query) {
68
+ const data = await this.client.proxy.channels(channelId).users('@me').threads.archived.private.get({ query });
69
+ return {
70
+ threads: data.threads.map(thread => (0, channels_1.default)(thread, this.client)),
71
+ members: data.members,
72
+ hasMore: data.has_more,
73
+ };
74
+ }
75
+ }
76
+ exports.ThreadShorter = ThreadShorter;
@@ -17,7 +17,7 @@ export declare class WebhookShorter extends BaseShorter {
17
17
  * @param options The optional parameters including token and reason.
18
18
  * @returns A Promise that resolves when the webhook is edited.
19
19
  */
20
- edit(webhookId: string, body: RESTPatchAPIWebhookWithTokenJSONBody | RESTPatchAPIWebhookJSONBody, options: WebhookShorterOptionalParams): Promise<import("discord-api-types/v10").RESTGetAPIWebhookWithTokenResult>;
20
+ edit(webhookId: string, body: RESTPatchAPIWebhookWithTokenJSONBody | RESTPatchAPIWebhookJSONBody, options: WebhookShorterOptionalParams): Promise<Webhook>;
21
21
  /**
22
22
  * Fetches a webhook.
23
23
  * @param webhookId The ID of the webhook.
@@ -32,9 +32,15 @@ class WebhookShorter extends base_1.BaseShorter {
32
32
  */
33
33
  edit(webhookId, body, options) {
34
34
  if (options.token) {
35
- return this.client.proxy.webhooks(webhookId)(options.token).patch({ body, reason: options.reason, auth: false });
35
+ return this.client.proxy
36
+ .webhooks(webhookId)(options.token)
37
+ .patch({ body, reason: options.reason, auth: false })
38
+ .then(webhook => new structures_1.Webhook(this.client, webhook));
36
39
  }
37
- return this.client.proxy.webhooks(webhookId).patch({ body, reason: options.reason });
40
+ return this.client.proxy
41
+ .webhooks(webhookId)
42
+ .patch({ body, reason: options.reason })
43
+ .then(webhook => new structures_1.Webhook(this.client, webhook));
38
44
  }
39
45
  /**
40
46
  * Fetches a webhook.
@@ -1,7 +1,7 @@
1
1
  import type { Identify } from '..';
2
- import type { ImageURLOptions } from '../../api';
2
+ import type { CDNUrlOptions } from '../../api';
3
3
  import type { UsingClient } from '../../commands';
4
- export type ImageOptions = ImageURLOptions;
4
+ export type ImageOptions = CDNUrlOptions;
5
5
  export type MethodContext<T = {}> = Identify<{
6
6
  client: UsingClient;
7
7
  } & T>;
@@ -1,17 +1,20 @@
1
- import type { APIActionRowComponent, APIEmbed, APIInteractionResponseCallbackData, APIInteractionResponseChannelMessageWithSource, APIMessageActionRowComponent, APIModalInteractionResponse, RESTPatchAPIChannelMessageJSONBody, RESTPatchAPIWebhookWithTokenMessageJSONBody, RESTPostAPIChannelMessageJSONBody, RESTPostAPIWebhookWithTokenJSONBody } from 'discord-api-types/v10';
1
+ import type { APIActionRowComponent, APIEmbed, APIInteractionResponseCallbackData, APIInteractionResponseChannelMessageWithSource, APIMessageActionRowComponent, APIModalInteractionResponse, RESTAPIPollCreate, RESTPatchAPIChannelMessageJSONBody, RESTPatchAPIWebhookWithTokenMessageJSONBody, RESTPostAPIChannelMessageJSONBody, RESTPostAPIWebhookWithTokenJSONBody } from 'discord-api-types/v10';
2
2
  import type { RawFile } from '../../api';
3
- import type { ActionRow, Attachment, AttachmentBuilder, BuilderComponents, Embed, Modal } from '../../builders';
3
+ import type { ActionRow, Attachment, AttachmentBuilder, BuilderComponents, Embed, Modal, PollBuilder } from '../../builders';
4
4
  import type { OmitInsert } from './util';
5
5
  export interface ResolverProps {
6
6
  embeds?: Embed[] | APIEmbed[] | undefined;
7
7
  components?: APIActionRowComponent<APIMessageActionRowComponent>[] | ActionRow<BuilderComponents>[] | undefined;
8
8
  files?: AttachmentBuilder[] | Attachment[] | RawFile[] | undefined;
9
9
  }
10
- export type MessageCreateBodyRequest = OmitInsert<RESTPostAPIChannelMessageJSONBody, 'components' | 'embeds', ResolverProps>;
10
+ export interface SendResolverProps extends ResolverProps {
11
+ poll?: PollBuilder | RESTAPIPollCreate | undefined;
12
+ }
13
+ export type MessageCreateBodyRequest = OmitInsert<RESTPostAPIChannelMessageJSONBody, 'components' | 'embeds' | 'poll', SendResolverProps>;
11
14
  export type MessageUpdateBodyRequest = OmitInsert<RESTPatchAPIChannelMessageJSONBody, 'components' | 'embeds', ResolverProps>;
12
- export type MessageWebhookCreateBodyRequest = OmitInsert<RESTPostAPIWebhookWithTokenJSONBody, 'components' | 'embeds', ResolverProps>;
15
+ export type MessageWebhookCreateBodyRequest = OmitInsert<RESTPostAPIWebhookWithTokenJSONBody, 'components' | 'embeds' | 'poll', SendResolverProps>;
13
16
  export type MessageWebhookUpdateBodyRequest = OmitInsert<RESTPatchAPIWebhookWithTokenMessageJSONBody, 'components' | 'embeds', ResolverProps>;
14
17
  export type InteractionMessageUpdateBodyRequest = OmitInsert<RESTPatchAPIWebhookWithTokenMessageJSONBody, 'components' | 'embeds', ResolverProps>;
15
18
  export type ComponentInteractionMessageUpdate = OmitInsert<APIInteractionResponseCallbackData, 'components' | 'embeds', ResolverProps>;
16
- export type InteractionCreateBodyRequest = OmitInsert<APIInteractionResponseChannelMessageWithSource['data'], 'components' | 'embeds', ResolverProps>;
19
+ export type InteractionCreateBodyRequest = OmitInsert<APIInteractionResponseChannelMessageWithSource['data'], 'components' | 'embeds' | 'poll', SendResolverProps>;
17
20
  export type ModalCreateBodyRequest = APIModalInteractionResponse['data'] | Modal;
@@ -8,7 +8,7 @@ class LinkButtonComponent extends BaseComponent_1.BaseComponent {
8
8
  return this.data.style;
9
9
  }
10
10
  get url() {
11
- // @ts-ignore
11
+ // @ts-expect-error
12
12
  return this.data.url;
13
13
  }
14
14
  get label() {
@@ -46,7 +46,7 @@ export declare class ComponentContext<Type extends keyof ComponentCommandInterac
46
46
  * Edits the response of the interaction.
47
47
  * @param body - The updated body of the response.
48
48
  */
49
- editResponse(body: InteractionMessageUpdateBodyRequest): Promise<Message>;
49
+ editResponse(body: InteractionMessageUpdateBodyRequest): Promise<WebhookMessage>;
50
50
  /**
51
51
  * Updates the interaction with new data.
52
52
  * @param body - The updated body of the interaction.
@@ -16,23 +16,6 @@ type COMPONENTS = {
16
16
  timeout?: NodeJS.Timeout;
17
17
  __run: (customId: string | string[] | RegExp, callback: ComponentCallback) => any;
18
18
  };
19
- export interface ComponentHandlerLike {
20
- readonly values: Map<string, COMPONENTS>;
21
- readonly commands: (ComponentCommand | ModalCommand)[];
22
- readonly modals: Map<string, ModalSubmitCallback> | LimitedCollection<string, ModalSubmitCallback>;
23
- onFail: ComponentHandler['onFail'];
24
- createComponentCollector: ComponentHandler['createComponentCollector'];
25
- hasModal: ComponentHandler['hasModal'];
26
- onModalSubmit: ComponentHandler['onModalSubmit'];
27
- executeModal: ComponentHandler['executeModal'];
28
- hasComponent: ComponentHandler['hasComponent'];
29
- executeComponent: ComponentHandler['executeComponent'];
30
- onComponent: ComponentHandler['onComponent'];
31
- load: ComponentHandler['load'];
32
- reload: ComponentHandler['reload'];
33
- reloadAll: ComponentHandler['reloadAll'];
34
- onMessageDelete: ComponentHandler['onMessageDelete'];
35
- }
36
19
  export declare class ComponentHandler extends BaseHandler {
37
20
  protected client: UsingClient;
38
21
  onFail: OnFailCallback;
@@ -57,5 +40,11 @@ export declare class ComponentHandler extends BaseHandler {
57
40
  reloadAll(): Promise<void>;
58
41
  executeComponent(interaction: ComponentInteraction): Promise<void>;
59
42
  executeModal(interaction: ModalSubmitInteraction): Promise<void>;
43
+ setHandlers({ callback }: {
44
+ callback: ComponentHandler['callback'];
45
+ }): void;
46
+ callback: (file: {
47
+ new (): ModalCommand | ComponentCommand;
48
+ }) => ModalCommand | ComponentCommand | false;
60
49
  }
61
50
  export {};
@@ -121,7 +121,9 @@ class ComponentHandler extends common_1.BaseHandler {
121
121
  for (let i = 0; i < paths.length; i++) {
122
122
  let component;
123
123
  try {
124
- component = new paths[i].file();
124
+ component = this.callback(paths[i].file);
125
+ if (!component)
126
+ continue;
125
127
  }
126
128
  catch (e) {
127
129
  if (e instanceof Error && e.message === 'paths[i].file is not a constructor') {
@@ -138,7 +140,6 @@ class ComponentHandler extends common_1.BaseHandler {
138
140
  continue;
139
141
  component.__filePath = paths[i].path;
140
142
  this.commands.push(component);
141
- await this.__callback?.(component);
142
143
  }
143
144
  }
144
145
  async reload(path) {
@@ -201,5 +202,9 @@ class ComponentHandler extends common_1.BaseHandler {
201
202
  }
202
203
  }
203
204
  }
205
+ setHandlers({ callback }) {
206
+ this.callback = callback;
207
+ }
208
+ callback = (file) => new file();
204
209
  }
205
210
  exports.ComponentHandler = ComponentHandler;
@@ -1,23 +1,14 @@
1
1
  import type { GatewayDispatchPayload } from 'discord-api-types/v10';
2
2
  import type { Client, WorkerClient } from '../client';
3
- import { BaseHandler, type MakeRequired, type OnFailCallback, type SnakeCase } from '../common';
3
+ import { BaseHandler, type MakeRequired, type SnakeCase } from '../common';
4
4
  import type { ClientEvents } from '../events/hooks';
5
5
  import type { ClientEvent, ClientNameEvents } from './event';
6
- type EventValue = MakeRequired<ClientEvent, '__filePath'> & {
6
+ export type EventValue = MakeRequired<ClientEvent, '__filePath'> & {
7
7
  fired?: boolean;
8
8
  };
9
- type GatewayEvents = Uppercase<SnakeCase<keyof ClientEvents>>;
10
- export interface EventHandlerLike {
11
- runEvent: EventHandler['runEvent'];
12
- execute: EventHandler['execute'];
13
- load: EventHandler['load'];
14
- reload: EventHandler['reload'];
15
- reloadAll: EventHandler['reloadAll'];
16
- values: EventHandler['values'];
17
- onFail: EventHandler['onFail'];
18
- }
9
+ export type GatewayEvents = Uppercase<SnakeCase<keyof ClientEvents>>;
19
10
  export declare class EventHandler extends BaseHandler {
20
- onFail: OnFailCallback;
11
+ onFail: (event: GatewayEvents, err: unknown) => void;
21
12
  protected filter: (path: string) => boolean;
22
13
  values: Partial<Record<GatewayEvents, EventValue>>;
23
14
  load(eventsDir: string): Promise<void>;
@@ -25,5 +16,8 @@ export declare class EventHandler extends BaseHandler {
25
16
  runEvent(name: GatewayEvents, client: Client | WorkerClient, packet: any, shardId: number): Promise<void>;
26
17
  reload(name: ClientNameEvents): Promise<any>;
27
18
  reloadAll(): Promise<void>;
19
+ setHandlers({ callback }: {
20
+ callback: EventHandler['callback'];
21
+ }): void;
22
+ callback: (file: ClientEvent) => ClientEvent | false;
28
23
  }
29
- export {};