seyfert 1.2.3 → 1.3.1

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 (125) hide show
  1. package/lib/api/Routes/channels.d.ts +15 -1
  2. package/lib/api/api.js +5 -1
  3. package/lib/api/shared.d.ts +3 -1
  4. package/lib/api/utils/utils.d.ts +1 -1
  5. package/lib/api/utils/utils.js +2 -2
  6. package/lib/builders/Poll.d.ts +16 -0
  7. package/lib/builders/Poll.js +48 -0
  8. package/lib/builders/index.d.ts +1 -0
  9. package/lib/builders/index.js +1 -0
  10. package/lib/cache/adapters/index.d.ts +1 -0
  11. package/lib/cache/adapters/index.js +1 -0
  12. package/lib/cache/adapters/limited.d.ts +50 -0
  13. package/lib/cache/adapters/limited.js +188 -0
  14. package/lib/cache/index.d.ts +5 -2
  15. package/lib/cache/index.js +38 -7
  16. package/lib/cache/resources/channels.d.ts +2 -1
  17. package/lib/cache/resources/default/base.d.ts +3 -3
  18. package/lib/cache/resources/default/base.js +8 -3
  19. package/lib/cache/resources/default/guild-based.d.ts +2 -1
  20. package/lib/cache/resources/default/guild-based.js +7 -3
  21. package/lib/cache/resources/default/guild-related.d.ts +2 -1
  22. package/lib/cache/resources/default/guild-related.js +7 -3
  23. package/lib/cache/resources/emojis.d.ts +2 -0
  24. package/lib/cache/resources/emojis.js +4 -0
  25. package/lib/cache/resources/guilds.d.ts +2 -0
  26. package/lib/cache/resources/guilds.js +4 -0
  27. package/lib/cache/resources/members.d.ts +2 -0
  28. package/lib/cache/resources/members.js +5 -1
  29. package/lib/cache/resources/messages.d.ts +15 -0
  30. package/lib/cache/resources/messages.js +53 -0
  31. package/lib/cache/resources/overwrites.d.ts +2 -0
  32. package/lib/cache/resources/overwrites.js +4 -0
  33. package/lib/cache/resources/presence.d.ts +1 -0
  34. package/lib/cache/resources/presence.js +4 -0
  35. package/lib/cache/resources/roles.d.ts +2 -0
  36. package/lib/cache/resources/roles.js +4 -0
  37. package/lib/cache/resources/stage-instances.d.ts +1 -0
  38. package/lib/cache/resources/stage-instances.js +5 -1
  39. package/lib/cache/resources/stickers.d.ts +2 -0
  40. package/lib/cache/resources/stickers.js +4 -0
  41. package/lib/cache/resources/threads.d.ts +2 -0
  42. package/lib/cache/resources/threads.js +4 -0
  43. package/lib/cache/resources/users.d.ts +2 -0
  44. package/lib/cache/resources/users.js +4 -0
  45. package/lib/cache/resources/voice-states.d.ts +2 -1
  46. package/lib/cache/resources/voice-states.js +8 -4
  47. package/lib/client/base.d.ts +25 -13
  48. package/lib/client/base.js +33 -8
  49. package/lib/client/client.d.ts +6 -5
  50. package/lib/client/client.js +13 -1
  51. package/lib/client/oninteractioncreate.js +2 -2
  52. package/lib/client/onmessagecreate.js +2 -2
  53. package/lib/client/workerclient.d.ts +3 -3
  54. package/lib/client/workerclient.js +18 -3
  55. package/lib/collection.d.ts +8 -3
  56. package/lib/collection.js +22 -4
  57. package/lib/commands/applications/chat.d.ts +8 -14
  58. package/lib/commands/applications/chat.js +2 -20
  59. package/lib/commands/applications/chatcontext.d.ts +1 -1
  60. package/lib/commands/applications/menucontext.d.ts +1 -1
  61. package/lib/commands/handler.d.ts +11 -7
  62. package/lib/commands/handler.js +43 -14
  63. package/lib/common/index.d.ts +2 -0
  64. package/lib/common/index.js +2 -0
  65. package/lib/common/it/utils.d.ts +0 -1
  66. package/lib/common/it/utils.js +0 -1
  67. package/lib/common/shorters/channels.d.ts +5 -3
  68. package/lib/common/shorters/channels.js +24 -10
  69. package/lib/common/shorters/guilds.d.ts +7 -6
  70. package/lib/common/shorters/guilds.js +23 -4
  71. package/lib/common/shorters/interaction.d.ts +13 -0
  72. package/lib/common/shorters/interaction.js +61 -0
  73. package/lib/common/shorters/messages.d.ts +6 -3
  74. package/lib/common/shorters/messages.js +33 -15
  75. package/lib/common/shorters/roles.d.ts +3 -3
  76. package/lib/common/shorters/roles.js +12 -17
  77. package/lib/common/shorters/templates.d.ts +7 -6
  78. package/lib/common/shorters/templates.js +28 -6
  79. package/lib/common/shorters/threads.d.ts +39 -0
  80. package/lib/common/shorters/threads.js +76 -0
  81. package/lib/common/shorters/webhook.d.ts +1 -1
  82. package/lib/common/shorters/webhook.js +8 -2
  83. package/lib/common/types/util.d.ts +8 -2
  84. package/lib/common/types/write.d.ts +8 -5
  85. package/lib/components/ButtonComponent.js +1 -1
  86. package/lib/components/componentcontext.d.ts +1 -1
  87. package/lib/components/handler.d.ts +6 -17
  88. package/lib/components/handler.js +7 -2
  89. package/lib/events/handler.d.ts +8 -14
  90. package/lib/events/handler.js +9 -4
  91. package/lib/events/hooks/auto_moderation.d.ts +5 -1
  92. package/lib/events/hooks/guild.d.ts +692 -23
  93. package/lib/events/hooks/guild.js +2 -2
  94. package/lib/events/hooks/integration.d.ts +52 -47
  95. package/lib/events/hooks/interactions.d.ts +1 -1
  96. package/lib/events/hooks/invite.d.ts +67 -3
  97. package/lib/events/hooks/message.d.ts +96 -12
  98. package/lib/events/hooks/message.js +18 -7
  99. package/lib/events/hooks/presence.d.ts +48 -2
  100. package/lib/events/hooks/thread.d.ts +155 -18
  101. package/lib/events/hooks/typing.d.ts +13 -1
  102. package/lib/events/hooks/voice.d.ts +13 -1
  103. package/lib/langs/handler.d.ts +4 -8
  104. package/lib/langs/handler.js +7 -2
  105. package/lib/structures/AutoModerationRule.d.ts +7 -7
  106. package/lib/structures/AutoModerationRule.js +2 -1
  107. package/lib/structures/Guild.d.ts +15 -13
  108. package/lib/structures/GuildRole.d.ts +5 -5
  109. package/lib/structures/GuildTemplate.d.ts +10 -10
  110. package/lib/structures/Interaction.d.ts +4 -4
  111. package/lib/structures/Interaction.js +27 -48
  112. package/lib/structures/Message.d.ts +5 -3
  113. package/lib/structures/Message.js +5 -0
  114. package/lib/structures/Poll.d.ts +15 -0
  115. package/lib/structures/Poll.js +26 -0
  116. package/lib/structures/User.js +2 -2
  117. package/lib/structures/Webhook.d.ts +2 -2
  118. package/lib/structures/channels.d.ts +6 -3
  119. package/lib/structures/channels.js +16 -8
  120. package/lib/structures/extra/Permissions.d.ts +1 -0
  121. package/lib/structures/index.d.ts +1 -0
  122. package/lib/structures/index.js +1 -0
  123. package/lib/websocket/SharedTypes.d.ts +7 -2
  124. package/lib/websocket/discord/shard.js +1 -1
  125. package/package.json +8 -8
@@ -1,6 +1,6 @@
1
1
  import type { GuildWidgetStyle, RESTGetAPICurrentUserGuildsQuery, RESTPatchAPIAutoModerationRuleJSONBody, RESTPatchAPIChannelJSONBody, RESTPatchAPIGuildChannelPositionsJSONBody, RESTPatchAPIGuildStickerJSONBody, RESTPostAPIAutoModerationRuleJSONBody, RESTPostAPIGuildChannelJSONBody, RESTPostAPIGuildsJSONBody } from 'discord-api-types/v10';
2
- import type { ObjectToLower } from '..';
3
- import { AnonymousGuild, Guild, GuildMember, Sticker, type CreateStickerBodyRequest } from '../../structures';
2
+ import { type ObjectToLower } from '..';
3
+ import { AnonymousGuild, AutoModerationRule, Guild, GuildMember, Sticker, type CreateStickerBodyRequest } from '../../structures';
4
4
  import { BaseShorter } from './base';
5
5
  export declare class GuildShorter extends BaseShorter {
6
6
  /**
@@ -75,6 +75,7 @@ export declare class GuildShorter extends BaseShorter {
75
75
  * @param body The data containing the new positions of channels.
76
76
  */
77
77
  editPositions: (guildId: string, body: RESTPatchAPIGuildChannelPositionsJSONBody) => Promise<never>;
78
+ addFollower: (channelId: string, webhook_channel_id: string, reason?: string) => Promise<import("discord-api-types/v10").APIFollowedChannel>;
78
79
  };
79
80
  /**
80
81
  * Provides access to auto-moderation rule-related functionality in a guild.
@@ -85,14 +86,14 @@ export declare class GuildShorter extends BaseShorter {
85
86
  * @param guildId The ID of the guild.
86
87
  * @returns A Promise that resolves to an array of auto-moderation rules.
87
88
  */
88
- list: (guildId: string) => Promise<import("discord-api-types/v10").RESTGetAPIAutoModerationRulesResult>;
89
+ list: (guildId: string) => Promise<AutoModerationRule[]>;
89
90
  /**
90
91
  * Creates a new auto-moderation rule in the guild.
91
92
  * @param guildId The ID of the guild.
92
93
  * @param body The data for creating the auto-moderation rule.
93
94
  * @returns A Promise that resolves to the created auto-moderation rule.
94
95
  */
95
- create: (guildId: string, body: RESTPostAPIAutoModerationRuleJSONBody) => Promise<import("discord-api-types/v10").APIAutoModerationRule>;
96
+ create: (guildId: string, body: RESTPostAPIAutoModerationRuleJSONBody) => Promise<AutoModerationRule>;
96
97
  /**
97
98
  * Deletes an auto-moderation rule from the guild.
98
99
  * @param guildId The ID of the guild.
@@ -107,7 +108,7 @@ export declare class GuildShorter extends BaseShorter {
107
108
  * @param ruleId The ID of the rule to fetch.
108
109
  * @returns A Promise that resolves to the fetched auto-moderation rule.
109
110
  */
110
- fetch: (guildId: string, ruleId: string) => Promise<import("discord-api-types/v10").APIAutoModerationRule>;
111
+ fetch: (guildId: string, ruleId: string) => Promise<AutoModerationRule>;
111
112
  /**
112
113
  * Edits an auto-moderation rule in the guild.
113
114
  * @param guildId The ID of the guild.
@@ -116,7 +117,7 @@ export declare class GuildShorter extends BaseShorter {
116
117
  * @param reason The reason for editing the rule.
117
118
  * @returns A Promise that resolves to the edited auto-moderation rule.
118
119
  */
119
- edit: (guildId: string, ruleId: string, body: ObjectToLower<RESTPatchAPIAutoModerationRuleJSONBody>, reason?: string) => Promise<import("discord-api-types/v10").APIAutoModerationRule>;
120
+ edit: (guildId: string, ruleId: string, body: ObjectToLower<RESTPatchAPIAutoModerationRuleJSONBody>, reason?: string) => Promise<AutoModerationRule>;
120
121
  };
121
122
  /**
122
123
  * Provides access to sticker-related functionality in a guild.
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.GuildShorter = void 0;
7
+ const __1 = require("..");
7
8
  const builders_1 = require("../../builders");
8
9
  const structures_1 = require("../../structures");
9
10
  const channels_1 = __importDefault(require("../../structures/channels"));
@@ -154,6 +155,14 @@ class GuildShorter extends base_1.BaseShorter {
154
155
  * @param body The data containing the new positions of channels.
155
156
  */
156
157
  editPositions: (guildId, body) => this.client.proxy.guilds(guildId).channels.patch({ body }),
158
+ addFollower: async (channelId, webhook_channel_id, reason) => {
159
+ return this.client.proxy.channels(channelId).followers.post({
160
+ body: {
161
+ webhook_channel_id,
162
+ },
163
+ reason,
164
+ });
165
+ },
157
166
  };
158
167
  }
159
168
  /**
@@ -166,14 +175,18 @@ class GuildShorter extends base_1.BaseShorter {
166
175
  * @param guildId The ID of the guild.
167
176
  * @returns A Promise that resolves to an array of auto-moderation rules.
168
177
  */
169
- list: (guildId) => this.client.proxy.guilds(guildId)['auto-moderation'].rules.get(),
178
+ list: (guildId) => this.client.proxy
179
+ .guilds(guildId)['auto-moderation'].rules.get()
180
+ .then(rules => rules.map(rule => new structures_1.AutoModerationRule(this.client, rule))),
170
181
  /**
171
182
  * Creates a new auto-moderation rule in the guild.
172
183
  * @param guildId The ID of the guild.
173
184
  * @param body The data for creating the auto-moderation rule.
174
185
  * @returns A Promise that resolves to the created auto-moderation rule.
175
186
  */
176
- create: (guildId, body) => this.client.proxy.guilds(guildId)['auto-moderation'].rules.post({ body }),
187
+ create: (guildId, body) => this.client.proxy
188
+ .guilds(guildId)['auto-moderation'].rules.post({ body })
189
+ .then(rule => new structures_1.AutoModerationRule(this.client, rule)),
177
190
  /**
178
191
  * Deletes an auto-moderation rule from the guild.
179
192
  * @param guildId The ID of the guild.
@@ -191,7 +204,10 @@ class GuildShorter extends base_1.BaseShorter {
191
204
  * @returns A Promise that resolves to the fetched auto-moderation rule.
192
205
  */
193
206
  fetch: (guildId, ruleId) => {
194
- return this.client.proxy.guilds(guildId)['auto-moderation'].rules(ruleId).get();
207
+ return this.client.proxy
208
+ .guilds(guildId)['auto-moderation'].rules(ruleId)
209
+ .get()
210
+ .then(rule => new structures_1.AutoModerationRule(this.client, rule));
195
211
  },
196
212
  /**
197
213
  * Edits an auto-moderation rule in the guild.
@@ -202,7 +218,10 @@ class GuildShorter extends base_1.BaseShorter {
202
218
  * @returns A Promise that resolves to the edited auto-moderation rule.
203
219
  */
204
220
  edit: (guildId, ruleId, body, reason) => {
205
- return this.client.proxy.guilds(guildId)['auto-moderation'].rules(ruleId).patch({ body, reason });
221
+ return this.client.proxy
222
+ .guilds(guildId)['auto-moderation'].rules(ruleId)
223
+ .patch({ body: (0, __1.toSnakeCase)(body), reason })
224
+ .then(rule => new structures_1.AutoModerationRule(this.client, rule));
206
225
  },
207
226
  };
208
227
  }
@@ -0,0 +1,13 @@
1
+ import { WebhookMessage, type ReplyInteractionBody } from '../..';
2
+ import type { InteractionMessageUpdateBodyRequest, MessageWebhookCreateBodyRequest } from '../types/write';
3
+ import { BaseShorter } from './base';
4
+ export declare class InteractionShorter extends BaseShorter {
5
+ reply(id: string, token: string, body: ReplyInteractionBody): Promise<never>;
6
+ fetchResponse(token: string, messageId: string): Promise<WebhookMessage | undefined>;
7
+ fetchOriginal(token: string): Promise<WebhookMessage | undefined>;
8
+ editMessage(token: string, messageId: string, body: InteractionMessageUpdateBodyRequest): Promise<WebhookMessage>;
9
+ editOriginal(token: string, body: InteractionMessageUpdateBodyRequest): Promise<WebhookMessage>;
10
+ deleteResponse(interactionId: string, token: string, messageId: string): Promise<void | undefined>;
11
+ deleteOriginal(interactionId: string, token: string): Promise<void | undefined>;
12
+ followup(token: string, { files, ...body }: MessageWebhookCreateBodyRequest): Promise<WebhookMessage>;
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.
@@ -49,10 +49,16 @@ export type NonFalsy<T> = T extends false | 0 | '' | null | undefined | 0n ? nev
49
49
  export type CamelCase<S extends string> = S extends `${infer P1}_${infer P2}${infer P3}` ? `${Lowercase<P1>}${Uppercase<P2>}${CamelCase<P3>}` : Lowercase<S>;
50
50
  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>;
51
51
  export type ObjectToLower<T> = Identify<{
52
- [K in keyof T as CamelCase<Exclude<K, symbol | number>>]: T[K] extends unknown[] ? Identify<ObjectToLower<T[K][0]>[]> : T[K] extends object ? Identify<ObjectToLower<T[K]>> : T[K];
52
+ [K in keyof T as CamelCase<Exclude<K, symbol | number>>]: T[K] extends unknown[] ? Identify<ObjectToLower<T[K][0]>[]> : T[K] extends object ? Identify<ObjectToLower<T[K]>> : AuxIsStrictlyUndefined<T[K]> extends true ? undefined : ObjectToLowerUndefined<T[K]>;
53
+ }>;
54
+ export type ObjectToLowerUndefined<T> = T extends unknown[] ? ObjectToLower<T[0]>[] : Identify<{
55
+ [K in keyof T as CamelCase<Exclude<K, symbol | number>>]?: T[K] extends unknown[] ? ObjectToLower<T[K][0]>[] : T[K] extends object ? ObjectToLower<T[K]> : T[K];
53
56
  }>;
54
57
  export type ObjectToSnake<T> = Identify<{
55
- [K in keyof T as SnakeCase<Exclude<K, symbol | number>>]: T[K] extends unknown[] ? Identify<ObjectToSnake<T[K][0]>[]> : T[K] extends object ? Identify<ObjectToSnake<T[K]>> : T[K];
58
+ [K in keyof T as SnakeCase<Exclude<K, symbol | number>>]: T[K] extends unknown[] ? Identify<ObjectToSnake<T[K][0]>[]> : T[K] extends object ? Identify<ObjectToSnake<T[K]>> : AuxIsStrictlyUndefined<T[K]> extends true ? undefined : ObjectToSnakeUndefined<T[K]>;
59
+ }>;
60
+ export type ObjectToSnakeUndefined<T> = T extends unknown[] ? ObjectToSnake<T[0]>[] : Identify<{
61
+ [K in keyof T as SnakeCase<Exclude<K, symbol | number>>]?: T[K] extends unknown[] ? ObjectToSnake<T[K][0]>[] : T[K] extends object ? ObjectToSnake<T[K]> : T[K];
56
62
  }>;
57
63
  export type UnionToTuple<U, A extends any[] = []> = (U extends void ? void : (arg: () => U) => never) extends (arg: infer I) => void ? I extends () => infer W ? UnionToTuple<Exclude<U, W>, [W, ...A]> : A : never;
58
64
  export type KeysWithUndefined<T> = {