seyfert 0.1.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.
- package/LICENSE +190 -0
- package/README.md +57 -0
- package/lib/api/CDN.d.ts +220 -0
- package/lib/api/CDN.js +236 -0
- package/lib/api/REST.d.ts +127 -0
- package/lib/api/REST.js +424 -0
- package/lib/api/Router.d.ts +17 -0
- package/lib/api/Router.js +63 -0
- package/lib/api/Routes/applications.d.ts +46 -0
- package/lib/api/Routes/applications.js +2 -0
- package/lib/api/Routes/cdn.d.ts +66 -0
- package/lib/api/Routes/cdn.js +2 -0
- package/lib/api/Routes/channels.d.ts +109 -0
- package/lib/api/Routes/channels.js +2 -0
- package/lib/api/Routes/gateway.d.ts +11 -0
- package/lib/api/Routes/gateway.js +2 -0
- package/lib/api/Routes/guilds.d.ts +171 -0
- package/lib/api/Routes/guilds.js +2 -0
- package/lib/api/Routes/index.d.ts +13 -0
- package/lib/api/Routes/index.js +17 -0
- package/lib/api/Routes/interactions.d.ts +14 -0
- package/lib/api/Routes/interactions.js +2 -0
- package/lib/api/Routes/invites.d.ts +9 -0
- package/lib/api/Routes/invites.js +2 -0
- package/lib/api/Routes/stage-instances.d.ts +13 -0
- package/lib/api/Routes/stage-instances.js +2 -0
- package/lib/api/Routes/stickers.d.ts +11 -0
- package/lib/api/Routes/stickers.js +2 -0
- package/lib/api/Routes/users.d.ts +35 -0
- package/lib/api/Routes/users.js +2 -0
- package/lib/api/Routes/voice.d.ts +10 -0
- package/lib/api/Routes/voice.js +2 -0
- package/lib/api/Routes/webhooks.d.ts +29 -0
- package/lib/api/Routes/webhooks.js +2 -0
- package/lib/api/errors/DiscordAPIError.d.ts +51 -0
- package/lib/api/errors/DiscordAPIError.js +81 -0
- package/lib/api/errors/HTTPError.d.ts +20 -0
- package/lib/api/errors/HTTPError.js +28 -0
- package/lib/api/errors/RateLimitError.d.ts +19 -0
- package/lib/api/errors/RateLimitError.js +37 -0
- package/lib/api/handlers/BurstHandler.d.ts +51 -0
- package/lib/api/handlers/BurstHandler.js +124 -0
- package/lib/api/handlers/SequentialHandler.d.ts +81 -0
- package/lib/api/handlers/SequentialHandler.js +365 -0
- package/lib/api/handlers/Shared.d.ts +14 -0
- package/lib/api/handlers/Shared.js +125 -0
- package/lib/api/index.d.ts +5 -0
- package/lib/api/index.js +21 -0
- package/lib/api/interfaces/Handler.d.ts +21 -0
- package/lib/api/interfaces/Handler.js +2 -0
- package/lib/api/shared.d.ts +7 -0
- package/lib/api/shared.js +27 -0
- package/lib/api/utils/constants.d.ts +39 -0
- package/lib/api/utils/constants.js +50 -0
- package/lib/api/utils/types.d.ts +335 -0
- package/lib/api/utils/types.js +14 -0
- package/lib/api/utils/utils.d.ts +52 -0
- package/lib/api/utils/utils.js +159 -0
- package/lib/builders/ActionRow.d.ts +40 -0
- package/lib/builders/ActionRow.js +58 -0
- package/lib/builders/Attachment.d.ts +106 -0
- package/lib/builders/Attachment.js +196 -0
- package/lib/builders/Base.d.ts +10 -0
- package/lib/builders/Base.js +13 -0
- package/lib/builders/Button.d.ts +59 -0
- package/lib/builders/Button.js +94 -0
- package/lib/builders/MessageEmbed.d.ts +116 -0
- package/lib/builders/MessageEmbed.js +159 -0
- package/lib/builders/Modal.d.ts +111 -0
- package/lib/builders/Modal.js +162 -0
- package/lib/builders/SelectMenu.d.ts +201 -0
- package/lib/builders/SelectMenu.js +293 -0
- package/lib/builders/index.d.ts +12 -0
- package/lib/builders/index.js +54 -0
- package/lib/builders/types.d.ts +21 -0
- package/lib/builders/types.js +2 -0
- package/lib/cache/adapters/default.d.ts +24 -0
- package/lib/cache/adapters/default.js +118 -0
- package/lib/cache/adapters/index.d.ts +4 -0
- package/lib/cache/adapters/index.js +20 -0
- package/lib/cache/adapters/redis.d.ts +35 -0
- package/lib/cache/adapters/redis.js +180 -0
- package/lib/cache/adapters/types.d.ts +25 -0
- package/lib/cache/adapters/types.js +2 -0
- package/lib/cache/adapters/workeradapter.d.ts +24 -0
- package/lib/cache/adapters/workeradapter.js +76 -0
- package/lib/cache/index.d.ts +97 -0
- package/lib/cache/index.js +394 -0
- package/lib/cache/resources/channels.d.ts +7 -0
- package/lib/cache/resources/channels.js +20 -0
- package/lib/cache/resources/default/base.d.ts +25 -0
- package/lib/cache/resources/default/base.js +75 -0
- package/lib/cache/resources/default/guild-based.d.ts +33 -0
- package/lib/cache/resources/default/guild-based.js +91 -0
- package/lib/cache/resources/default/guild-related.d.ts +32 -0
- package/lib/cache/resources/default/guild-related.js +102 -0
- package/lib/cache/resources/emojis.d.ts +7 -0
- package/lib/cache/resources/emojis.js +17 -0
- package/lib/cache/resources/guilds.d.ts +10 -0
- package/lib/cache/resources/guilds.js +117 -0
- package/lib/cache/resources/members.d.ts +10 -0
- package/lib/cache/resources/members.js +41 -0
- package/lib/cache/resources/presence.d.ts +9 -0
- package/lib/cache/resources/presence.js +14 -0
- package/lib/cache/resources/roles.d.ts +7 -0
- package/lib/cache/resources/roles.js +17 -0
- package/lib/cache/resources/stage-instances.d.ts +5 -0
- package/lib/cache/resources/stage-instances.js +8 -0
- package/lib/cache/resources/stickers.d.ts +7 -0
- package/lib/cache/resources/stickers.js +17 -0
- package/lib/cache/resources/threads.d.ts +7 -0
- package/lib/cache/resources/threads.js +17 -0
- package/lib/cache/resources/users.d.ts +7 -0
- package/lib/cache/resources/users.js +17 -0
- package/lib/cache/resources/voice-states.d.ts +9 -0
- package/lib/cache/resources/voice-states.js +13 -0
- package/lib/client/base.d.ts +244 -0
- package/lib/client/base.js +178 -0
- package/lib/client/client.d.ts +32 -0
- package/lib/client/client.js +156 -0
- package/lib/client/httpclient.d.ts +21 -0
- package/lib/client/httpclient.js +143 -0
- package/lib/client/index.d.ts +4 -0
- package/lib/client/index.js +19 -0
- package/lib/client/oninteraction.d.ts +4 -0
- package/lib/client/oninteraction.js +180 -0
- package/lib/client/workerclient.d.ts +28 -0
- package/lib/client/workerclient.js +213 -0
- package/lib/collection.d.ts +233 -0
- package/lib/collection.js +371 -0
- package/lib/commands/applications/chat.d.ts +139 -0
- package/lib/commands/applications/chat.js +173 -0
- package/lib/commands/applications/chatcontext.d.ts +28 -0
- package/lib/commands/applications/chatcontext.js +53 -0
- package/lib/commands/applications/menu.d.ts +39 -0
- package/lib/commands/applications/menu.js +87 -0
- package/lib/commands/applications/menucontext.d.ts +25 -0
- package/lib/commands/applications/menucontext.js +64 -0
- package/lib/commands/applications/options.d.ts +67 -0
- package/lib/commands/applications/options.js +44 -0
- package/lib/commands/applications/shared.d.ts +35 -0
- package/lib/commands/applications/shared.js +2 -0
- package/lib/commands/decorators.d.ts +107 -0
- package/lib/commands/decorators.js +85 -0
- package/lib/commands/handler.d.ts +15 -0
- package/lib/commands/handler.js +140 -0
- package/lib/commands/index.d.ts +8 -0
- package/lib/commands/index.js +24 -0
- package/lib/commands/optionresolver.d.ts +49 -0
- package/lib/commands/optionresolver.js +146 -0
- package/lib/common/bot/watcher.d.ts +53 -0
- package/lib/common/bot/watcher.js +104 -0
- package/lib/common/index.d.ts +13 -0
- package/lib/common/index.js +30 -0
- package/lib/common/it/colors.d.ts +274 -0
- package/lib/common/it/colors.js +453 -0
- package/lib/common/it/constants.d.ts +36 -0
- package/lib/common/it/constants.js +40 -0
- package/lib/common/it/logger.d.ts +114 -0
- package/lib/common/it/logger.js +189 -0
- package/lib/common/it/utils.d.ts +107 -0
- package/lib/common/it/utils.js +275 -0
- package/lib/common/shorters/base.d.ts +5 -0
- package/lib/common/shorters/base.js +10 -0
- package/lib/common/shorters/channels.d.ts +90 -0
- package/lib/common/shorters/channels.js +95 -0
- package/lib/common/shorters/guilds.d.ts +389 -0
- package/lib/common/shorters/guilds.js +350 -0
- package/lib/common/shorters/members.d.ts +115 -0
- package/lib/common/shorters/members.js +179 -0
- package/lib/common/shorters/messages.d.ts +27 -0
- package/lib/common/shorters/messages.js +117 -0
- package/lib/common/shorters/roles.d.ts +12 -0
- package/lib/common/shorters/roles.js +51 -0
- package/lib/common/shorters/templates.d.ts +12 -0
- package/lib/common/shorters/templates.js +29 -0
- package/lib/common/shorters/users.d.ts +11 -0
- package/lib/common/shorters/users.js +42 -0
- package/lib/common/shorters/webhook.d.ts +33 -0
- package/lib/common/shorters/webhook.js +69 -0
- package/lib/common/types/options.d.ts +10 -0
- package/lib/common/types/options.js +2 -0
- package/lib/common/types/resolvables.d.ts +10 -0
- package/lib/common/types/resolvables.js +2 -0
- package/lib/common/types/util.d.ts +90 -0
- package/lib/common/types/util.js +2 -0
- package/lib/common/types/write.d.ts +21 -0
- package/lib/common/types/write.js +2 -0
- package/lib/components/ActionRow.d.ts +10 -0
- package/lib/components/ActionRow.js +13 -0
- package/lib/components/ButtonComponent.d.ts +19 -0
- package/lib/components/ButtonComponent.js +34 -0
- package/lib/components/ChannelSelectMenuComponent.d.ts +6 -0
- package/lib/components/ChannelSelectMenuComponent.js +12 -0
- package/lib/components/MentionableSelectMenuComponent.d.ts +4 -0
- package/lib/components/MentionableSelectMenuComponent.js +7 -0
- package/lib/components/RoleSelectMenuComponent.d.ts +4 -0
- package/lib/components/RoleSelectMenuComponent.js +7 -0
- package/lib/components/StringSelectMenuComponent.d.ts +6 -0
- package/lib/components/StringSelectMenuComponent.js +12 -0
- package/lib/components/TextInputComponent.d.ts +7 -0
- package/lib/components/TextInputComponent.js +14 -0
- package/lib/components/UserSelectMenuComponent.d.ts +4 -0
- package/lib/components/UserSelectMenuComponent.js +7 -0
- package/lib/components/command.d.ts +23 -0
- package/lib/components/command.js +15 -0
- package/lib/components/handler.d.ts +48 -0
- package/lib/components/handler.js +231 -0
- package/lib/components/index.d.ts +20 -0
- package/lib/components/index.js +55 -0
- package/lib/components/listener.d.ts +11 -0
- package/lib/components/listener.js +18 -0
- package/lib/events/event.d.ts +23 -0
- package/lib/events/event.js +2 -0
- package/lib/events/handler.d.ts +19 -0
- package/lib/events/handler.js +112 -0
- package/lib/events/hooks/application_command.d.ts +12 -0
- package/lib/events/hooks/application_command.js +8 -0
- package/lib/events/hooks/auto_moderation.d.ts +22 -0
- package/lib/events/hooks/auto_moderation.js +21 -0
- package/lib/events/hooks/channel.d.ts +11 -0
- package/lib/events/hooks/channel.js +24 -0
- package/lib/events/hooks/custom.d.ts +4 -0
- package/lib/events/hooks/custom.js +11 -0
- package/lib/events/hooks/dispatch.d.ts +5 -0
- package/lib/events/hooks/dispatch.js +12 -0
- package/lib/events/hooks/entitlement.d.ts +35 -0
- package/lib/events/hooks/entitlement.js +16 -0
- package/lib/events/hooks/guild.d.ts +228 -0
- package/lib/events/hooks/guild.js +101 -0
- package/lib/events/hooks/index.d.ts +23 -0
- package/lib/events/hooks/index.js +34 -0
- package/lib/events/hooks/integration.d.ts +94 -0
- package/lib/events/hooks/integration.js +27 -0
- package/lib/events/hooks/interactions.d.ts +4 -0
- package/lib/events/hooks/interactions.js +8 -0
- package/lib/events/hooks/invite.d.ts +21 -0
- package/lib/events/hooks/invite.js +12 -0
- package/lib/events/hooks/message.d.ts +69 -0
- package/lib/events/hooks/message.js +37 -0
- package/lib/events/hooks/presence.d.ts +27 -0
- package/lib/events/hooks/presence.js +8 -0
- package/lib/events/hooks/stage.d.ts +29 -0
- package/lib/events/hooks/stage.js +16 -0
- package/lib/events/hooks/thread.d.ts +198 -0
- package/lib/events/hooks/thread.js +29 -0
- package/lib/events/hooks/typing.d.ts +16 -0
- package/lib/events/hooks/typing.js +14 -0
- package/lib/events/hooks/user.d.ts +4 -0
- package/lib/events/hooks/user.js +8 -0
- package/lib/events/hooks/voice.d.ts +37 -0
- package/lib/events/hooks/voice.js +18 -0
- package/lib/events/hooks/webhook.d.ts +6 -0
- package/lib/events/hooks/webhook.js +8 -0
- package/lib/events/index.d.ts +2 -0
- package/lib/events/index.js +18 -0
- package/lib/index.d.ts +79 -0
- package/lib/index.js +104 -0
- package/lib/langs/handler.d.ts +11 -0
- package/lib/langs/handler.js +34 -0
- package/lib/langs/index.d.ts +2 -0
- package/lib/langs/index.js +18 -0
- package/lib/langs/router.d.ts +18 -0
- package/lib/langs/router.js +42 -0
- package/lib/structures/AnonymousGuild.d.ts +7 -0
- package/lib/structures/AnonymousGuild.js +11 -0
- package/lib/structures/AutoModerationRule.d.ts +22 -0
- package/lib/structures/AutoModerationRule.js +34 -0
- package/lib/structures/ClientUser.d.ts +25 -0
- package/lib/structures/ClientUser.js +52 -0
- package/lib/structures/Guild.d.ts +86 -0
- package/lib/structures/Guild.js +66 -0
- package/lib/structures/GuildEmoji.d.ts +29 -0
- package/lib/structures/GuildEmoji.js +47 -0
- package/lib/structures/GuildMember.d.ts +92 -0
- package/lib/structures/GuildMember.js +137 -0
- package/lib/structures/GuildPreview.d.ts +10 -0
- package/lib/structures/GuildPreview.js +14 -0
- package/lib/structures/GuildRole.d.ts +21 -0
- package/lib/structures/GuildRole.js +32 -0
- package/lib/structures/GuildTemplate.d.ts +23 -0
- package/lib/structures/GuildTemplate.js +36 -0
- package/lib/structures/Interaction.d.ts +152 -0
- package/lib/structures/Interaction.js +409 -0
- package/lib/structures/Message.d.ts +53 -0
- package/lib/structures/Message.js +123 -0
- package/lib/structures/Sticker.d.ts +27 -0
- package/lib/structures/Sticker.js +44 -0
- package/lib/structures/User.d.ts +20 -0
- package/lib/structures/User.js +37 -0
- package/lib/structures/Webhook.d.ts +42 -0
- package/lib/structures/Webhook.js +63 -0
- package/lib/structures/channels.d.ts +232 -0
- package/lib/structures/channels.js +366 -0
- package/lib/structures/extra/Base.d.ts +7 -0
- package/lib/structures/extra/Base.js +39 -0
- package/lib/structures/extra/BaseComponent.d.ts +9 -0
- package/lib/structures/extra/BaseComponent.js +12 -0
- package/lib/structures/extra/BaseGuild.d.ts +40 -0
- package/lib/structures/extra/BaseGuild.js +71 -0
- package/lib/structures/extra/BaseSelectMenuComponent.d.ts +9 -0
- package/lib/structures/extra/BaseSelectMenuComponent.js +13 -0
- package/lib/structures/extra/BitField.d.ts +14 -0
- package/lib/structures/extra/BitField.js +56 -0
- package/lib/structures/extra/DiscordBase.d.ts +18 -0
- package/lib/structures/extra/DiscordBase.js +28 -0
- package/lib/structures/extra/Permissions.d.ts +54 -0
- package/lib/structures/extra/Permissions.js +9 -0
- package/lib/structures/extra/functions.d.ts +11 -0
- package/lib/structures/extra/functions.js +69 -0
- package/lib/structures/index.d.ts +15 -0
- package/lib/structures/index.js +31 -0
- package/lib/websocket/SharedTypes.d.ts +128 -0
- package/lib/websocket/SharedTypes.js +2 -0
- package/lib/websocket/constants/index.d.ts +26 -0
- package/lib/websocket/constants/index.js +31 -0
- package/lib/websocket/discord/basesocket.d.ts +12 -0
- package/lib/websocket/discord/basesocket.js +37 -0
- package/lib/websocket/discord/events/memberUpdate.d.ts +16 -0
- package/lib/websocket/discord/events/memberUpdate.js +47 -0
- package/lib/websocket/discord/events/presenceUpdate.d.ts +24 -0
- package/lib/websocket/discord/events/presenceUpdate.js +46 -0
- package/lib/websocket/discord/handlemessage.d.ts +0 -0
- package/lib/websocket/discord/handlemessage.js +1 -0
- package/lib/websocket/discord/index.d.ts +4 -0
- package/lib/websocket/discord/index.js +20 -0
- package/lib/websocket/discord/memberUpdate.d.ts +16 -0
- package/lib/websocket/discord/memberUpdate.js +47 -0
- package/lib/websocket/discord/shard.d.ts +46 -0
- package/lib/websocket/discord/shard.js +278 -0
- package/lib/websocket/discord/sharder.d.ts +25 -0
- package/lib/websocket/discord/sharder.js +153 -0
- package/lib/websocket/discord/shared.d.ts +99 -0
- package/lib/websocket/discord/shared.js +8 -0
- package/lib/websocket/discord/worker.d.ts +43 -0
- package/lib/websocket/discord/worker.js +2 -0
- package/lib/websocket/discord/workermanager.d.ts +69 -0
- package/lib/websocket/discord/workermanager.js +273 -0
- package/lib/websocket/index.d.ts +3 -0
- package/lib/websocket/index.js +19 -0
- package/lib/websocket/structures/index.d.ts +117 -0
- package/lib/websocket/structures/index.js +261 -0
- package/lib/websocket/structures/timeout.d.ts +20 -0
- package/lib/websocket/structures/timeout.js +75 -0
- package/package.json +70 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageShorter = void 0;
|
|
4
|
+
const builders_1 = require("../../builders");
|
|
5
|
+
const structures_1 = require("../../structures");
|
|
6
|
+
const functions_1 = require("../../structures/extra/functions");
|
|
7
|
+
const base_1 = require("./base");
|
|
8
|
+
class MessageShorter extends base_1.BaseShorter {
|
|
9
|
+
get messages() {
|
|
10
|
+
return {
|
|
11
|
+
write: async (channelId, { files, ...body }) => {
|
|
12
|
+
const parsedFiles = files ? await (0, builders_1.resolveFiles)(files) : [];
|
|
13
|
+
const transformedBody = structures_1.MessagesMethods.transformMessageBody(body);
|
|
14
|
+
return this.client.proxy
|
|
15
|
+
.channels(channelId)
|
|
16
|
+
.messages.post({
|
|
17
|
+
body: transformedBody,
|
|
18
|
+
files: parsedFiles,
|
|
19
|
+
})
|
|
20
|
+
.then(message => {
|
|
21
|
+
this.client.components.onRequestMessage(body, message);
|
|
22
|
+
return new structures_1.Message(this.client, message);
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
edit: async (messageId, channelId, { files, ...body }) => {
|
|
26
|
+
const parsedFiles = files ? await (0, builders_1.resolveFiles)(files) : [];
|
|
27
|
+
return this.client.proxy
|
|
28
|
+
.channels(channelId)
|
|
29
|
+
.messages(messageId)
|
|
30
|
+
.patch({
|
|
31
|
+
body: structures_1.MessagesMethods.transformMessageBody(body),
|
|
32
|
+
files: parsedFiles,
|
|
33
|
+
})
|
|
34
|
+
.then(message => {
|
|
35
|
+
this.client.components.onRequestUpdateMessage(body, message);
|
|
36
|
+
return new structures_1.Message(this.client, message);
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
crosspost: (messageId, channelId, reason) => {
|
|
40
|
+
return this.client.proxy
|
|
41
|
+
.channels(channelId)
|
|
42
|
+
.messages(messageId)
|
|
43
|
+
.crosspost.post({ reason })
|
|
44
|
+
.then(m => new structures_1.Message(this.client, m));
|
|
45
|
+
},
|
|
46
|
+
delete: (messageId, channelId, reason) => {
|
|
47
|
+
return this.client.proxy
|
|
48
|
+
.channels(channelId)
|
|
49
|
+
.messages(messageId)
|
|
50
|
+
.delete({ reason })
|
|
51
|
+
.then(() => {
|
|
52
|
+
return this.client.components.onMessageDelete(messageId);
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
fetch: async (messageId, channelId) => {
|
|
56
|
+
return this.client.proxy
|
|
57
|
+
.channels(channelId)
|
|
58
|
+
.messages(messageId)
|
|
59
|
+
.get()
|
|
60
|
+
.then(x => new structures_1.Message(this.client, x));
|
|
61
|
+
},
|
|
62
|
+
purge: (messages, channelId, reason) => {
|
|
63
|
+
return this.client.proxy.channels(channelId).messages['bulk-delete'].post({ body: { messages }, reason });
|
|
64
|
+
},
|
|
65
|
+
reactions: this.reactions,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
get reactions() {
|
|
69
|
+
return {
|
|
70
|
+
add: async (messageId, channelId, emoji) => {
|
|
71
|
+
const rawEmoji = await (0, functions_1.resolveEmoji)(emoji, this.client.cache);
|
|
72
|
+
if (!rawEmoji) {
|
|
73
|
+
throw new Error('Emoji no resolvable');
|
|
74
|
+
}
|
|
75
|
+
return this.client.proxy
|
|
76
|
+
.channels(channelId)
|
|
77
|
+
.messages(messageId)
|
|
78
|
+
.reactions((0, functions_1.encodeEmoji)(rawEmoji))('@me')
|
|
79
|
+
.put({});
|
|
80
|
+
},
|
|
81
|
+
delete: async (messageId, channelId, emoji, userId = '@me') => {
|
|
82
|
+
const rawEmoji = await (0, functions_1.resolveEmoji)(emoji, this.client.cache);
|
|
83
|
+
if (!rawEmoji) {
|
|
84
|
+
throw new Error('Emoji no resolvable');
|
|
85
|
+
}
|
|
86
|
+
return this.client.proxy
|
|
87
|
+
.channels(channelId)
|
|
88
|
+
.messages(messageId)
|
|
89
|
+
.reactions((0, functions_1.encodeEmoji)(rawEmoji))(userId)
|
|
90
|
+
.delete();
|
|
91
|
+
},
|
|
92
|
+
fetch: async (messageId, channelId, emoji, query) => {
|
|
93
|
+
const rawEmoji = await (0, functions_1.resolveEmoji)(emoji, this.client.cache);
|
|
94
|
+
if (!rawEmoji) {
|
|
95
|
+
throw new Error('Emoji no resolvable');
|
|
96
|
+
}
|
|
97
|
+
return this.client.proxy
|
|
98
|
+
.channels(channelId)
|
|
99
|
+
.messages(messageId)
|
|
100
|
+
.reactions((0, functions_1.encodeEmoji)(rawEmoji))
|
|
101
|
+
.get({ query })
|
|
102
|
+
.then(u => u.map(user => new structures_1.User(this.client, user)));
|
|
103
|
+
},
|
|
104
|
+
purge: async (messageId, channelId, emoji) => {
|
|
105
|
+
if (!emoji) {
|
|
106
|
+
return this.client.proxy.channels(channelId).messages(messageId).reactions.delete();
|
|
107
|
+
}
|
|
108
|
+
const rawEmoji = await (0, functions_1.resolveEmoji)(emoji, this.client.cache);
|
|
109
|
+
if (!rawEmoji) {
|
|
110
|
+
throw new Error('Emoji no resolvable');
|
|
111
|
+
}
|
|
112
|
+
return this.client.proxy.channels(channelId).messages(messageId).reactions((0, functions_1.encodeEmoji)(rawEmoji)).delete();
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.MessageShorter = MessageShorter;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RESTPatchAPIGuildRoleJSONBody, RESTPatchAPIGuildRolePositionsJSONBody, RESTPostAPIGuildRoleJSONBody } from 'discord-api-types/v10';
|
|
2
|
+
import { GuildRole } from '../../structures';
|
|
3
|
+
import { BaseShorter } from './base';
|
|
4
|
+
export declare class RoleShorter extends BaseShorter {
|
|
5
|
+
get roles(): {
|
|
6
|
+
create: (guildId: string, body: RESTPostAPIGuildRoleJSONBody, reason?: string) => Promise<any>;
|
|
7
|
+
list: (guildId: string, force?: boolean) => Promise<GuildRole[]>;
|
|
8
|
+
edit: (guildId: string, roleId: string, body: RESTPatchAPIGuildRoleJSONBody, reason?: string) => Promise<any>;
|
|
9
|
+
delete: (guildId: string, roleId: string, reason?: string) => Promise<void | undefined>;
|
|
10
|
+
editPositions: (guildId: string, body: RESTPatchAPIGuildRolePositionsJSONBody) => Promise<GuildRole[]>;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RoleShorter = void 0;
|
|
4
|
+
const structures_1 = require("../../structures");
|
|
5
|
+
const base_1 = require("./base");
|
|
6
|
+
class RoleShorter extends base_1.BaseShorter {
|
|
7
|
+
get roles() {
|
|
8
|
+
return {
|
|
9
|
+
create: (guildId, body, reason) => this.client.proxy
|
|
10
|
+
.guilds(guildId)
|
|
11
|
+
.roles.post({ body, reason })
|
|
12
|
+
.then(res => this.client.cache.roles?.setIfNI('Guilds', res.id, guildId, res)),
|
|
13
|
+
list: async (guildId, force = false) => {
|
|
14
|
+
let roles = [];
|
|
15
|
+
if (!force) {
|
|
16
|
+
roles = (await this.client.cache.roles?.values(guildId)) ?? [];
|
|
17
|
+
if (roles.length) {
|
|
18
|
+
return roles.map(r => new structures_1.GuildRole(this.client, r, guildId));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
roles = await this.client.proxy.guilds(guildId).roles.get();
|
|
22
|
+
await this.client.cache.roles?.set(roles.map(r => [r.id, r]), guildId);
|
|
23
|
+
return roles.map(r => new structures_1.GuildRole(this.client, r, guildId));
|
|
24
|
+
},
|
|
25
|
+
edit: (guildId, roleId, body, reason) => {
|
|
26
|
+
return this.client.proxy
|
|
27
|
+
.guilds(guildId)
|
|
28
|
+
.roles(roleId)
|
|
29
|
+
.patch({ body, reason })
|
|
30
|
+
.then(res => this.client.cache.roles?.setIfNI('Guilds', roleId, guildId, res));
|
|
31
|
+
},
|
|
32
|
+
delete: (guildId, roleId, reason) => {
|
|
33
|
+
return this.client.proxy
|
|
34
|
+
.guilds(guildId)
|
|
35
|
+
.roles(roleId)
|
|
36
|
+
.delete({ reason })
|
|
37
|
+
.then(() => this.client.cache.roles?.removeIfNI('Guilds', roleId, guildId));
|
|
38
|
+
},
|
|
39
|
+
editPositions: async (guildId, body) => {
|
|
40
|
+
const roles = await this.client.proxy.guilds(guildId).roles.patch({
|
|
41
|
+
body,
|
|
42
|
+
});
|
|
43
|
+
if (!this.client.cache.hasRolesIntent) {
|
|
44
|
+
await this.client.cache.roles?.set(roles.map(x => [x.id, x]), guildId);
|
|
45
|
+
}
|
|
46
|
+
return roles.map(x => new structures_1.GuildRole(this.client, x, guildId));
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.RoleShorter = RoleShorter;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RESTPatchAPIGuildTemplateJSONBody, RESTPostAPIGuildTemplatesJSONBody } from 'discord-api-types/v10';
|
|
2
|
+
import { BaseShorter } from './base';
|
|
3
|
+
export declare class TemplateShorter extends BaseShorter {
|
|
4
|
+
get templates(): {
|
|
5
|
+
fetch: (code: string) => Promise<import("discord-api-types/v10").APITemplate>;
|
|
6
|
+
list: (guildId: string) => Promise<import("discord-api-types/v10").RESTGetAPIGuildTemplatesResult>;
|
|
7
|
+
create: (guildId: string, body: RESTPostAPIGuildTemplatesJSONBody) => Promise<import("discord-api-types/v10").APITemplate>;
|
|
8
|
+
sync: (guildId: string, code: string) => Promise<import("discord-api-types/v10").APITemplate>;
|
|
9
|
+
edit: (guildId: string, code: string, body: RESTPatchAPIGuildTemplateJSONBody) => Promise<import("discord-api-types/v10").APITemplate>;
|
|
10
|
+
delete: (guildId: string, code: string) => Promise<import("discord-api-types/v10").APITemplate>;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TemplateShorter = void 0;
|
|
4
|
+
const base_1 = require("./base");
|
|
5
|
+
class TemplateShorter extends base_1.BaseShorter {
|
|
6
|
+
get templates() {
|
|
7
|
+
return {
|
|
8
|
+
fetch: (code) => {
|
|
9
|
+
return this.client.proxy.guilds.templates(code).get();
|
|
10
|
+
},
|
|
11
|
+
list: (guildId) => {
|
|
12
|
+
return this.client.proxy.guilds(guildId).templates.get();
|
|
13
|
+
},
|
|
14
|
+
create: (guildId, body) => {
|
|
15
|
+
return this.client.proxy.guilds(guildId).templates.post({ body });
|
|
16
|
+
},
|
|
17
|
+
sync: (guildId, code) => {
|
|
18
|
+
return this.client.proxy.guilds(guildId).templates(code).put({});
|
|
19
|
+
},
|
|
20
|
+
edit: (guildId, code, body) => {
|
|
21
|
+
return this.client.proxy.guilds(guildId).templates(code).patch({ body });
|
|
22
|
+
},
|
|
23
|
+
delete: (guildId, code) => {
|
|
24
|
+
return this.client.proxy.guilds(guildId).templates(code).delete();
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.TemplateShorter = TemplateShorter;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DMChannel, User } from '../../structures';
|
|
2
|
+
import type { MessageCreateBodyRequest } from '../types/write';
|
|
3
|
+
import { BaseShorter } from './base';
|
|
4
|
+
export declare class UsersShorter extends BaseShorter {
|
|
5
|
+
get users(): {
|
|
6
|
+
createDM: (userId: string, force?: boolean) => Promise<DMChannel>;
|
|
7
|
+
deleteDM: (userId: string, reason?: string) => Promise<DMChannel>;
|
|
8
|
+
fetch: (userId: string, force?: boolean) => Promise<User>;
|
|
9
|
+
write: (userId: string, body: MessageCreateBodyRequest) => Promise<import("../../structures").Message>;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UsersShorter = void 0;
|
|
4
|
+
const structures_1 = require("../../structures");
|
|
5
|
+
const base_1 = require("./base");
|
|
6
|
+
class UsersShorter extends base_1.BaseShorter {
|
|
7
|
+
get users() {
|
|
8
|
+
return {
|
|
9
|
+
createDM: async (userId, force = false) => {
|
|
10
|
+
if (!force) {
|
|
11
|
+
const dm = await this.client.cache.channels?.get(userId);
|
|
12
|
+
if (dm)
|
|
13
|
+
return dm;
|
|
14
|
+
}
|
|
15
|
+
const data = await this.client.proxy.users('@me').channels.post({
|
|
16
|
+
body: { recipient_id: userId },
|
|
17
|
+
});
|
|
18
|
+
await this.client.cache.channels?.set(userId, '@me', data);
|
|
19
|
+
return new structures_1.DMChannel(this.client, data);
|
|
20
|
+
},
|
|
21
|
+
deleteDM: async (userId, reason) => {
|
|
22
|
+
const res = await this.client.proxy.channels(userId).delete({ reason });
|
|
23
|
+
await this.client.cache.channels?.removeIfNI(structures_1.BaseChannel.__intent__('@me'), res.id, '@me');
|
|
24
|
+
return new structures_1.DMChannel(this.client, res);
|
|
25
|
+
},
|
|
26
|
+
fetch: async (userId, force = false) => {
|
|
27
|
+
if (!force) {
|
|
28
|
+
const user = await this.client.cache.users?.get(userId);
|
|
29
|
+
if (user)
|
|
30
|
+
return user;
|
|
31
|
+
}
|
|
32
|
+
const data = await this.client.proxy.users(userId).get();
|
|
33
|
+
await this.client.cache.users?.patch(userId, data);
|
|
34
|
+
return new structures_1.User(this.client, data);
|
|
35
|
+
},
|
|
36
|
+
write: async (userId, body) => {
|
|
37
|
+
return (await this.client.users.createDM(userId)).messages.write(body);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.UsersShorter = UsersShorter;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { RESTPatchAPIWebhookJSONBody, RESTPatchAPIWebhookWithTokenJSONBody, RESTPostAPIWebhookWithTokenJSONBody } from '..';
|
|
2
|
+
import { type MessageWebhookMethodEditParams, type MessageWebhookMethodWriteParams, Webhook, WebhookMessage } from '../../structures';
|
|
3
|
+
import { BaseShorter } from './base';
|
|
4
|
+
export declare class WebhookShorter extends BaseShorter {
|
|
5
|
+
get webhooks(): {
|
|
6
|
+
delete: (webhookId: string, { token, reason }: WebhookShorterOptionalParams) => Promise<never>;
|
|
7
|
+
edit: (webhookId: string, body: RESTPatchAPIWebhookWithTokenJSONBody | RESTPatchAPIWebhookJSONBody, { token, reason }: WebhookShorterOptionalParams) => Promise<import("discord-api-types/rest/v10/webhook").RESTGetAPIWebhookWithTokenResult>;
|
|
8
|
+
fetch: (webhookId: string, token?: string) => Promise<Webhook>;
|
|
9
|
+
messages: {
|
|
10
|
+
write: (webhookId: string, token: string, { body: data, ...payload }: {
|
|
11
|
+
body: Omit<RESTPostAPIWebhookWithTokenJSONBody, "embeds" | "components"> & import("..").ResolverProps;
|
|
12
|
+
query?: import("discord-api-types/rest/v10/webhook").RESTPostAPIWebhookWithTokenQuery | undefined;
|
|
13
|
+
}) => Promise<WebhookMessage | null>;
|
|
14
|
+
edit: (webhookId: string, token: string, { messageId, body: data, ...json }: {
|
|
15
|
+
body: Omit<import("discord-api-types/rest/v10/webhook").RESTPatchAPIWebhookWithTokenMessageJSONBody, "embeds" | "components"> & import("..").ResolverProps;
|
|
16
|
+
messageId: string;
|
|
17
|
+
query?: import("discord-api-types/rest/v10/webhook").RESTGetAPIWebhookWithTokenMessageQuery | undefined;
|
|
18
|
+
}) => Promise<WebhookMessage>;
|
|
19
|
+
delete: (webhookId: string, token: string, messageId: string, reason?: string | undefined) => Promise<never>;
|
|
20
|
+
fetch: (webhookId: string, token: string, messageId: string, threadId?: string | undefined) => Promise<WebhookMessage | undefined>;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
get messages(): {
|
|
24
|
+
write: (webhookId: string, token: string, { body: data, ...payload }: MessageWebhookMethodWriteParams) => Promise<WebhookMessage | null>;
|
|
25
|
+
edit: (webhookId: string, token: string, { messageId, body: data, ...json }: MessageWebhookMethodEditParams) => Promise<WebhookMessage>;
|
|
26
|
+
delete: (webhookId: string, token: string, messageId: string, reason?: string) => Promise<never>;
|
|
27
|
+
fetch: (webhookId: string, token: string, messageId: string, threadId?: string) => Promise<WebhookMessage | undefined>;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export type WebhookShorterOptionalParams = Partial<{
|
|
31
|
+
token: string;
|
|
32
|
+
reason: string;
|
|
33
|
+
}>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebhookShorter = void 0;
|
|
4
|
+
const builders_1 = require("../../builders");
|
|
5
|
+
const structures_1 = require("../../structures");
|
|
6
|
+
const base_1 = require("./base");
|
|
7
|
+
class WebhookShorter extends base_1.BaseShorter {
|
|
8
|
+
get webhooks() {
|
|
9
|
+
return {
|
|
10
|
+
delete: (webhookId, { token, reason }) => {
|
|
11
|
+
if (token) {
|
|
12
|
+
return this.client.proxy.webhooks(webhookId)(token).delete({ reason, auth: false });
|
|
13
|
+
}
|
|
14
|
+
return this.client.proxy.webhooks(webhookId).delete({ reason });
|
|
15
|
+
},
|
|
16
|
+
edit: (webhookId, body, { token, reason }) => {
|
|
17
|
+
if (token) {
|
|
18
|
+
return this.client.proxy.webhooks(webhookId)(token).patch({ body, reason, auth: false });
|
|
19
|
+
}
|
|
20
|
+
return this.client.proxy.webhooks(webhookId).patch({ body, reason });
|
|
21
|
+
},
|
|
22
|
+
fetch: async (webhookId, token) => {
|
|
23
|
+
let webhook;
|
|
24
|
+
if (token) {
|
|
25
|
+
webhook = await this.client.proxy.webhooks(webhookId)(token).get({ auth: false });
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
webhook = await this.client.proxy.webhooks(webhookId).get();
|
|
29
|
+
}
|
|
30
|
+
return new structures_1.Webhook(this.client, webhook);
|
|
31
|
+
},
|
|
32
|
+
messages: this.messages,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
get messages() {
|
|
36
|
+
return {
|
|
37
|
+
write: async (webhookId, token, { body: data, ...payload }) => {
|
|
38
|
+
const { files, ...body } = data;
|
|
39
|
+
const transformedBody = structures_1.MessagesMethods.transformMessageBody(body);
|
|
40
|
+
const parsedFiles = files ? await (0, builders_1.resolveFiles)(files) : [];
|
|
41
|
+
return this.client.proxy
|
|
42
|
+
.webhooks(webhookId)(token)
|
|
43
|
+
.post({ ...payload, files: parsedFiles, body: transformedBody })
|
|
44
|
+
.then(m => (m?.id ? new structures_1.WebhookMessage(this.client, m, webhookId, token) : null));
|
|
45
|
+
},
|
|
46
|
+
edit: async (webhookId, token, { messageId, body: data, ...json }) => {
|
|
47
|
+
const { files, ...body } = data;
|
|
48
|
+
const transformedBody = structures_1.MessagesMethods.transformMessageBody(body);
|
|
49
|
+
const parsedFiles = files ? await (0, builders_1.resolveFiles)(files) : [];
|
|
50
|
+
return this.client.proxy
|
|
51
|
+
.webhooks(webhookId)(token)
|
|
52
|
+
.messages(messageId)
|
|
53
|
+
.patch({ ...json, auth: false, files: parsedFiles, body: transformedBody })
|
|
54
|
+
.then(m => new structures_1.WebhookMessage(this.client, m, webhookId, token));
|
|
55
|
+
},
|
|
56
|
+
delete: async (webhookId, token, messageId, reason) => {
|
|
57
|
+
return this.client.proxy.webhooks(webhookId)(token).messages(messageId).delete({ reason });
|
|
58
|
+
},
|
|
59
|
+
fetch: async (webhookId, token, messageId, threadId) => {
|
|
60
|
+
const message = await this.client.proxy
|
|
61
|
+
.webhooks(webhookId)(token)
|
|
62
|
+
.messages(messageId)
|
|
63
|
+
.get({ auth: false, query: { threadId } });
|
|
64
|
+
return message ? new structures_1.WebhookMessage(this.client, message, webhookId, token) : undefined;
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.WebhookShorter = WebhookShorter;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Identify } from '..';
|
|
2
|
+
import type { ImageURLOptions } from '../../api';
|
|
3
|
+
import type { BaseClient } from '../../client/base';
|
|
4
|
+
export type ImageOptions = ImageURLOptions;
|
|
5
|
+
export type MethodContext<T = {}> = Identify<{
|
|
6
|
+
client: BaseClient;
|
|
7
|
+
} & T>;
|
|
8
|
+
export type MessageWebhookPayload<Body, Extra = {}> = Identify<{
|
|
9
|
+
body: Body;
|
|
10
|
+
} & Extra>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { APIPartialEmoji, EmbedColors } from '..';
|
|
2
|
+
import type { Attachment, AttachmentDataType, AttachmentResolvable } from '../../builders';
|
|
3
|
+
import type { GuildMember } from '../../structures';
|
|
4
|
+
export type EmojiResolvable = string | Partial<APIPartialEmoji> | `<${string | undefined}:${string}:${string}>`;
|
|
5
|
+
export type GuildMemberResolvable = string | Partial<GuildMember>;
|
|
6
|
+
export type ColorResolvable = `#${string}` | number | keyof typeof EmbedColors | 'Random' | [number, number, number];
|
|
7
|
+
export type ImageResolvable = {
|
|
8
|
+
data: AttachmentResolvable;
|
|
9
|
+
type: AttachmentDataType;
|
|
10
|
+
} | Attachment;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { GatewayIntentBits, PermissionFlagsBits } from '..';
|
|
2
|
+
export type ToClass<T, This> = new (...args: any[]) => {
|
|
3
|
+
[K in keyof T]: T[K] extends (...args: any[]) => any ? ReturnType<T[K]> extends Promise<T> ? (...args: Parameters<T[K]>) => Promise<This> : ReturnType<T[K]> extends T ? (...args: Parameters<T[K]>) => This : T[K] : T[K];
|
|
4
|
+
};
|
|
5
|
+
export type StringToNumber<T extends string> = T extends `${infer N extends number}` ? N : never;
|
|
6
|
+
export type MakePartial<T, K extends keyof T> = T & {
|
|
7
|
+
[P in K]?: T[P];
|
|
8
|
+
};
|
|
9
|
+
export type DeepPartial<T> = {
|
|
10
|
+
[K in keyof T]?: T[K] extends Record<any, any> ? DeepPartial<T[K]> : T[K] extends (infer I)[] ? DeepPartial<I>[] : T[K];
|
|
11
|
+
};
|
|
12
|
+
export type OmitInsert<T, K extends keyof T, I> = I extends [] ? Omit<T, K> & I[number] : Omit<T, K> & I;
|
|
13
|
+
export type IntentStrings = (keyof typeof GatewayIntentBits)[];
|
|
14
|
+
export type PermissionStrings = (keyof typeof PermissionFlagsBits)[];
|
|
15
|
+
export type RestOrArray<T> = T[] | [T[]];
|
|
16
|
+
export interface StructWhen<Prop = any, State extends keyof StructWhen = 'cached'> {
|
|
17
|
+
cached: Prop | undefined;
|
|
18
|
+
api: State extends 'api' ? Prop : undefined;
|
|
19
|
+
create: State extends 'create' ? Prop : undefined;
|
|
20
|
+
}
|
|
21
|
+
export type StructStates = keyof StructWhen;
|
|
22
|
+
export type StructPropState<Prop, State extends StructStates, Select extends StructStates> = StructWhen<Prop, Select>[State];
|
|
23
|
+
export type WithID<More> = {
|
|
24
|
+
id: string;
|
|
25
|
+
} & More;
|
|
26
|
+
export type Tail<A> = A extends [unknown, ...infer rest] ? rest : A extends [unknown] ? [] : A extends (infer first)[] ? first[] : never;
|
|
27
|
+
export type ValueOf<T> = T[keyof T];
|
|
28
|
+
export type ArrayFirsElement<A> = A extends [...infer arr] ? arr[0] : never;
|
|
29
|
+
export type RestToKeys<T extends unknown[]> = T extends [infer V, ...infer Keys] ? {
|
|
30
|
+
[K in Extract<Keys[number], string>]: V;
|
|
31
|
+
} : never;
|
|
32
|
+
export type Identify<T> = T extends infer U ? {
|
|
33
|
+
[K in keyof U]: U[K];
|
|
34
|
+
} : never;
|
|
35
|
+
export type TypeArray<T> = T | T[];
|
|
36
|
+
export type When<T extends boolean, A, B = never> = T extends true ? A : B;
|
|
37
|
+
export type If<T extends boolean, A, B = null> = T extends true ? A : B extends null ? A | null : B;
|
|
38
|
+
export type PickPartial<T, K extends keyof T> = {
|
|
39
|
+
[P in keyof T]?: T[P] | undefined;
|
|
40
|
+
} & {
|
|
41
|
+
[P in K]: T[P];
|
|
42
|
+
};
|
|
43
|
+
export type MakeRequired<T, K extends keyof T> = T & {
|
|
44
|
+
[P in K]-?: NonFalsy<T[P]>;
|
|
45
|
+
};
|
|
46
|
+
export type NonFalsy<T> = T extends false | 0 | '' | null | undefined | 0n ? never : T;
|
|
47
|
+
export type CamelCase<S extends string> = S extends `${infer P1}_${infer P2}${infer P3}` ? `${Lowercase<P1>}${Uppercase<P2>}${CamelCase<P3>}` : Lowercase<S>;
|
|
48
|
+
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>;
|
|
49
|
+
export type ObjectToLower<T> = Identify<{
|
|
50
|
+
[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];
|
|
51
|
+
}>;
|
|
52
|
+
export type ObjectToSnake<T> = Identify<{
|
|
53
|
+
[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];
|
|
54
|
+
}>;
|
|
55
|
+
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;
|
|
56
|
+
export type KeysWithUndefined<T> = {
|
|
57
|
+
[K in keyof T]-?: undefined extends T[K] ? K : null extends T[K] ? K : never;
|
|
58
|
+
}[keyof T];
|
|
59
|
+
type OptionalizeAux<T extends object> = Identify<{
|
|
60
|
+
[K in KeysWithUndefined<T>]?: T[K] extends ObjectLiteral ? Optionalize<T[K]> : T[K];
|
|
61
|
+
} & {
|
|
62
|
+
[K in Exclude<keyof T, KeysWithUndefined<T>>]: T[K] extends ObjectLiteral ? Optionalize<T[K]> : T[K];
|
|
63
|
+
}>;
|
|
64
|
+
/**
|
|
65
|
+
* Makes all of properties in T optional when they're null | undefined
|
|
66
|
+
* it is recursive
|
|
67
|
+
*/
|
|
68
|
+
export type Optionalize<T> = T extends object ? T extends Array<unknown> ? number extends T['length'] ? T[number] extends object ? Array<OptionalizeAux<T[number]>> : T : Partial<T> : OptionalizeAux<T> : T;
|
|
69
|
+
export type ObjectLiteral<T = unknown> = {
|
|
70
|
+
[K in PropertyKey]: T;
|
|
71
|
+
};
|
|
72
|
+
export type DropT<T, R> = {
|
|
73
|
+
[P in keyof T as T[P] extends R ? never : P]: T[P] extends R ? never : T[P];
|
|
74
|
+
};
|
|
75
|
+
export type DropTI<T, U> = {
|
|
76
|
+
[P in keyof T as U extends T[P] ? never : P]: U extends T[P] ? never : T[P];
|
|
77
|
+
};
|
|
78
|
+
export type KeepT<T, R> = {
|
|
79
|
+
[P in keyof T as T[P] extends R ? P : never]: T[P] extends R ? T[P] : never;
|
|
80
|
+
};
|
|
81
|
+
export type KeepTI<T, U> = {
|
|
82
|
+
[P in keyof T as U extends T[P] ? P : never]: U extends T[P] ? T[P] : never;
|
|
83
|
+
};
|
|
84
|
+
export type Clean<T> = DropT<T, never>;
|
|
85
|
+
export type PartialAvoid<U, T> = Identify<KeepT<T, U> & Partial<T>>;
|
|
86
|
+
export type PartialClass<T> = PartialAvoid<Function, T>;
|
|
87
|
+
export type AtLeastOne<T, U = {
|
|
88
|
+
[K in keyof T]: Pick<T, K>;
|
|
89
|
+
}> = Partial<T> & U[keyof U];
|
|
90
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { APIActionRowComponent, APIEmbed, APIInteractionResponseCallbackData, APIInteractionResponseChannelMessageWithSource, APIMessageActionRowComponent, APIModalInteractionResponse, RESTPatchAPIChannelMessageJSONBody, RESTPatchAPIWebhookWithTokenMessageJSONBody, RESTPostAPIChannelMessageJSONBody, RESTPostAPIWebhookWithTokenJSONBody } from '..';
|
|
2
|
+
import type { RawFile } from '../../api';
|
|
3
|
+
import type { ActionRow, Attachment, BuilderComponents, Embed, Modal, TextInput } from '../../builders';
|
|
4
|
+
import type { ComponentsListener } from '../../components/listener';
|
|
5
|
+
import type { OmitInsert } from './util';
|
|
6
|
+
export type BodyModalComponentProper = {
|
|
7
|
+
components?: ActionRow<TextInput>[] | undefined;
|
|
8
|
+
};
|
|
9
|
+
export interface ResolverProps {
|
|
10
|
+
embeds?: Embed[] | APIEmbed[] | undefined;
|
|
11
|
+
components?: ComponentsListener<BuilderComponents> | APIActionRowComponent<APIMessageActionRowComponent>[] | ActionRow<BuilderComponents>[] | undefined;
|
|
12
|
+
files?: Attachment[] | RawFile[] | undefined;
|
|
13
|
+
}
|
|
14
|
+
export type MessageCreateBodyRequest = OmitInsert<RESTPostAPIChannelMessageJSONBody, 'components' | 'embeds', ResolverProps>;
|
|
15
|
+
export type MessageUpdateBodyRequest = OmitInsert<RESTPatchAPIChannelMessageJSONBody, 'components' | 'embeds', ResolverProps>;
|
|
16
|
+
export type MessageWebhookCreateBodyRequest = OmitInsert<RESTPostAPIWebhookWithTokenJSONBody, 'components' | 'embeds', ResolverProps>;
|
|
17
|
+
export type MessageWebhookUpdateBodyRequest = OmitInsert<RESTPatchAPIWebhookWithTokenMessageJSONBody, 'components' | 'embeds', ResolverProps>;
|
|
18
|
+
export type InteractionMessageUpdateBodyRequest = OmitInsert<RESTPatchAPIWebhookWithTokenMessageJSONBody, 'components' | 'embeds', ResolverProps>;
|
|
19
|
+
export type ComponentInteractionMessageUpdate = OmitInsert<APIInteractionResponseCallbackData, 'components' | 'embeds', ResolverProps>;
|
|
20
|
+
export type InteractionCreateBodyRequest = OmitInsert<APIInteractionResponseChannelMessageWithSource['data'], 'components' | 'embeds', ResolverProps>;
|
|
21
|
+
export type ModalCreateBodyRequest = APIModalInteractionResponse['data'] | Modal;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { APIMessageActionRowComponent, ComponentType } from '../common';
|
|
2
|
+
import { BaseComponent } from '../structures/extra/BaseComponent';
|
|
3
|
+
import type { ActionRowMessageComponents } from './index';
|
|
4
|
+
export declare class MessageActionRowComponent<T extends ActionRowMessageComponents> extends BaseComponent<ComponentType.ActionRow> {
|
|
5
|
+
constructor(data: {
|
|
6
|
+
type: ComponentType.ActionRow;
|
|
7
|
+
components: APIMessageActionRowComponent[];
|
|
8
|
+
});
|
|
9
|
+
components: T[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageActionRowComponent = void 0;
|
|
4
|
+
const BaseComponent_1 = require("../structures/extra/BaseComponent");
|
|
5
|
+
const index_1 = require("./index");
|
|
6
|
+
class MessageActionRowComponent extends BaseComponent_1.BaseComponent {
|
|
7
|
+
constructor(data) {
|
|
8
|
+
super(data);
|
|
9
|
+
this.components = data.components.map(index_1.componentFactory);
|
|
10
|
+
}
|
|
11
|
+
components;
|
|
12
|
+
}
|
|
13
|
+
exports.MessageActionRowComponent = MessageActionRowComponent;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { APIButtonComponentWithCustomId, APIButtonComponentWithURL, APIMessageComponentEmoji, ComponentType } from '../common';
|
|
2
|
+
import { ButtonStyle } from '../common';
|
|
3
|
+
import { BaseComponent } from '../structures/extra/BaseComponent';
|
|
4
|
+
export declare class LinkButtonComponent extends BaseComponent<ComponentType.Button> {
|
|
5
|
+
constructor(data: APIButtonComponentWithURL);
|
|
6
|
+
style: ButtonStyle;
|
|
7
|
+
label?: string;
|
|
8
|
+
emoji?: APIMessageComponentEmoji;
|
|
9
|
+
disabled: boolean;
|
|
10
|
+
url: string;
|
|
11
|
+
}
|
|
12
|
+
export type ButtonStyleExludeLink = Exclude<ButtonStyle, ButtonStyle.Link>;
|
|
13
|
+
export declare class ButtonComponent extends BaseComponent<ComponentType.Button> {
|
|
14
|
+
constructor(data: APIButtonComponentWithCustomId);
|
|
15
|
+
style: ButtonStyleExludeLink;
|
|
16
|
+
label?: string;
|
|
17
|
+
emoji?: APIMessageComponentEmoji;
|
|
18
|
+
disabled: boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ButtonComponent = exports.LinkButtonComponent = void 0;
|
|
4
|
+
const common_1 = require("../common");
|
|
5
|
+
const BaseComponent_1 = require("../structures/extra/BaseComponent");
|
|
6
|
+
class LinkButtonComponent extends BaseComponent_1.BaseComponent {
|
|
7
|
+
constructor(data) {
|
|
8
|
+
super(data);
|
|
9
|
+
this.label = data.label;
|
|
10
|
+
this.emoji = data.emoji;
|
|
11
|
+
this.disabled = !!data.disabled;
|
|
12
|
+
this.url = data.url;
|
|
13
|
+
}
|
|
14
|
+
style = common_1.ButtonStyle.Link;
|
|
15
|
+
label;
|
|
16
|
+
emoji;
|
|
17
|
+
disabled;
|
|
18
|
+
url;
|
|
19
|
+
}
|
|
20
|
+
exports.LinkButtonComponent = LinkButtonComponent;
|
|
21
|
+
class ButtonComponent extends BaseComponent_1.BaseComponent {
|
|
22
|
+
constructor(data) {
|
|
23
|
+
super(data);
|
|
24
|
+
this.style = data.style;
|
|
25
|
+
this.label = data.label;
|
|
26
|
+
this.emoji = data.emoji;
|
|
27
|
+
this.disabled = !!data.disabled;
|
|
28
|
+
}
|
|
29
|
+
style;
|
|
30
|
+
label;
|
|
31
|
+
emoji;
|
|
32
|
+
disabled;
|
|
33
|
+
}
|
|
34
|
+
exports.ButtonComponent = ButtonComponent;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { APIChannelSelectComponent, ChannelType, ComponentType } from '../common';
|
|
2
|
+
import { BaseSelectMenuComponent } from '../structures/extra/BaseSelectMenuComponent';
|
|
3
|
+
export declare class ChannelSelectMenuComponent extends BaseSelectMenuComponent<ComponentType.ChannelSelect> {
|
|
4
|
+
constructor(data: APIChannelSelectComponent);
|
|
5
|
+
channelTypes?: ChannelType[];
|
|
6
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChannelSelectMenuComponent = void 0;
|
|
4
|
+
const BaseSelectMenuComponent_1 = require("../structures/extra/BaseSelectMenuComponent");
|
|
5
|
+
class ChannelSelectMenuComponent extends BaseSelectMenuComponent_1.BaseSelectMenuComponent {
|
|
6
|
+
constructor(data) {
|
|
7
|
+
super(data);
|
|
8
|
+
this.channelTypes = data.channel_types;
|
|
9
|
+
}
|
|
10
|
+
channelTypes;
|
|
11
|
+
}
|
|
12
|
+
exports.ChannelSelectMenuComponent = ChannelSelectMenuComponent;
|