@buape/carbon 0.8.0 → 0.10.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/dist/package.json +7 -7
- package/dist/src/abstracts/AnySelectMenu.d.ts +2 -1
- package/dist/src/abstracts/AnySelectMenu.d.ts.map +1 -1
- package/dist/src/abstracts/AnySelectMenu.js +6 -0
- package/dist/src/abstracts/AnySelectMenu.js.map +1 -1
- package/dist/src/abstracts/AnySelectMenuInteraction.d.ts +0 -1
- package/dist/src/abstracts/AnySelectMenuInteraction.d.ts.map +1 -1
- package/dist/src/abstracts/AnySelectMenuInteraction.js +0 -2
- package/dist/src/abstracts/AnySelectMenuInteraction.js.map +1 -1
- package/dist/src/abstracts/BaseChannel.d.ts +10 -1
- package/dist/src/abstracts/BaseChannel.d.ts.map +1 -1
- package/dist/src/abstracts/BaseChannel.js +13 -0
- package/dist/src/abstracts/BaseChannel.js.map +1 -1
- package/dist/src/abstracts/BaseCommand.d.ts +18 -8
- package/dist/src/abstracts/BaseCommand.d.ts.map +1 -1
- package/dist/src/abstracts/BaseCommand.js +24 -7
- package/dist/src/abstracts/BaseCommand.js.map +1 -1
- package/dist/src/abstracts/BaseComponentInteraction.d.ts +0 -1
- package/dist/src/abstracts/BaseComponentInteraction.d.ts.map +1 -1
- package/dist/src/abstracts/BaseComponentInteraction.js +3 -3
- package/dist/src/abstracts/BaseComponentInteraction.js.map +1 -1
- package/dist/src/abstracts/BaseGuildChannel.d.ts +3 -2
- package/dist/src/abstracts/BaseGuildChannel.d.ts.map +1 -1
- package/dist/src/abstracts/BaseGuildChannel.js +5 -3
- package/dist/src/abstracts/BaseGuildChannel.js.map +1 -1
- package/dist/src/abstracts/BaseGuildTextChannel.d.ts +1 -1
- package/dist/src/abstracts/BaseGuildTextChannel.d.ts.map +1 -1
- package/dist/src/abstracts/BaseInteraction.d.ts +45 -2
- package/dist/src/abstracts/BaseInteraction.d.ts.map +1 -1
- package/dist/src/abstracts/BaseInteraction.js +99 -14
- package/dist/src/abstracts/BaseInteraction.js.map +1 -1
- package/dist/src/abstracts/BaseMessageInteractiveComponent.d.ts +18 -12
- package/dist/src/abstracts/BaseMessageInteractiveComponent.d.ts.map +1 -1
- package/dist/src/abstracts/BaseMessageInteractiveComponent.js +18 -18
- package/dist/src/abstracts/BaseMessageInteractiveComponent.js.map +1 -1
- package/dist/src/abstracts/BaseModalComponent.d.ts +16 -10
- package/dist/src/abstracts/BaseModalComponent.d.ts.map +1 -1
- package/dist/src/abstracts/BaseModalComponent.js +25 -17
- package/dist/src/abstracts/BaseModalComponent.js.map +1 -1
- package/dist/src/abstracts/GuildThreadOnlyChannel.d.ts +11 -4
- package/dist/src/abstracts/GuildThreadOnlyChannel.d.ts.map +1 -1
- package/dist/src/abstracts/GuildThreadOnlyChannel.js +14 -1
- package/dist/src/abstracts/GuildThreadOnlyChannel.js.map +1 -1
- package/dist/src/abstracts/Plugin.d.ts +1 -1
- package/dist/src/abstracts/Plugin.d.ts.map +1 -1
- package/dist/src/classes/Client.d.ts +32 -8
- package/dist/src/classes/Client.d.ts.map +1 -1
- package/dist/src/classes/Client.js +76 -17
- package/dist/src/classes/Client.js.map +1 -1
- package/dist/src/classes/ClientWithCaching.d.ts +51 -0
- package/dist/src/classes/ClientWithCaching.d.ts.map +1 -0
- package/dist/src/classes/ClientWithCaching.js +108 -0
- package/dist/src/classes/ClientWithCaching.js.map +1 -0
- package/dist/src/classes/Command.d.ts +10 -2
- package/dist/src/classes/Command.d.ts.map +1 -1
- package/dist/src/classes/Command.js +12 -1
- package/dist/src/classes/Command.js.map +1 -1
- package/dist/src/classes/Listener.d.ts +20 -0
- package/dist/src/classes/Listener.d.ts.map +1 -1
- package/dist/src/classes/Listener.js +116 -14
- package/dist/src/classes/Listener.js.map +1 -1
- package/dist/src/classes/Modal.d.ts +19 -2
- package/dist/src/classes/Modal.d.ts.map +1 -1
- package/dist/src/classes/Modal.js +14 -0
- package/dist/src/classes/Modal.js.map +1 -1
- package/dist/src/classes/RequestClient.d.ts +7 -5
- package/dist/src/classes/RequestClient.d.ts.map +1 -1
- package/dist/src/classes/RequestClient.js +28 -16
- package/dist/src/classes/RequestClient.js.map +1 -1
- package/dist/src/classes/components/Button.d.ts +3 -1
- package/dist/src/classes/components/Button.d.ts.map +1 -1
- package/dist/src/classes/components/Button.js +10 -1
- package/dist/src/classes/components/Button.js.map +1 -1
- package/dist/src/classes/components/ChannelSelectMenu.d.ts +2 -1
- package/dist/src/classes/components/ChannelSelectMenu.d.ts.map +1 -1
- package/dist/src/classes/components/ChannelSelectMenu.js +6 -0
- package/dist/src/classes/components/ChannelSelectMenu.js.map +1 -1
- package/dist/src/classes/components/Container.d.ts +0 -3
- package/dist/src/classes/components/Container.d.ts.map +1 -1
- package/dist/src/classes/components/Container.js +0 -3
- package/dist/src/classes/components/Container.js.map +1 -1
- package/dist/src/classes/components/MentionableSelectMenu.d.ts +2 -1
- package/dist/src/classes/components/MentionableSelectMenu.d.ts.map +1 -1
- package/dist/src/classes/components/MentionableSelectMenu.js +6 -0
- package/dist/src/classes/components/MentionableSelectMenu.js.map +1 -1
- package/dist/src/classes/components/RoleSelectMenu.d.ts +2 -1
- package/dist/src/classes/components/RoleSelectMenu.d.ts.map +1 -1
- package/dist/src/classes/components/RoleSelectMenu.js +6 -0
- package/dist/src/classes/components/RoleSelectMenu.js.map +1 -1
- package/dist/src/classes/components/StringSelectMenu.d.ts +2 -1
- package/dist/src/classes/components/StringSelectMenu.d.ts.map +1 -1
- package/dist/src/classes/components/StringSelectMenu.js +6 -0
- package/dist/src/classes/components/StringSelectMenu.js.map +1 -1
- package/dist/src/classes/components/UserSelectMenu.d.ts +2 -1
- package/dist/src/classes/components/UserSelectMenu.d.ts.map +1 -1
- package/dist/src/classes/components/UserSelectMenu.js +6 -0
- package/dist/src/classes/components/UserSelectMenu.js.map +1 -1
- package/dist/src/functions/enforceChoicesLimit.d.ts +3 -0
- package/dist/src/functions/enforceChoicesLimit.d.ts.map +1 -0
- package/dist/src/functions/enforceChoicesLimit.js +17 -0
- package/dist/src/functions/enforceChoicesLimit.js.map +1 -0
- package/dist/src/functions/errorsMapper.d.ts.map +1 -1
- package/dist/src/functions/errorsMapper.js +13 -1
- package/dist/src/functions/errorsMapper.js.map +1 -1
- package/dist/src/index.d.ts +8 -54
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +9 -5
- package/dist/src/index.js.map +1 -1
- package/dist/src/internals/AutocompleteInteraction.d.ts +9 -3
- package/dist/src/internals/AutocompleteInteraction.d.ts.map +1 -1
- package/dist/src/internals/AutocompleteInteraction.js +13 -3
- package/dist/src/internals/AutocompleteInteraction.js.map +1 -1
- package/dist/src/internals/ButtonInteraction.d.ts +0 -1
- package/dist/src/internals/ButtonInteraction.d.ts.map +1 -1
- package/dist/src/internals/ButtonInteraction.js +0 -2
- package/dist/src/internals/ButtonInteraction.js.map +1 -1
- package/dist/src/internals/Cache.d.ts +76 -0
- package/dist/src/internals/Cache.d.ts.map +1 -0
- package/dist/src/internals/Cache.js +122 -0
- package/dist/src/internals/Cache.js.map +1 -0
- package/dist/src/internals/CommandHandler.d.ts +2 -1
- package/dist/src/internals/CommandHandler.d.ts.map +1 -1
- package/dist/src/internals/CommandHandler.js +44 -13
- package/dist/src/internals/CommandHandler.js.map +1 -1
- package/dist/src/internals/CommandInteraction.d.ts +7 -1
- package/dist/src/internals/CommandInteraction.d.ts.map +1 -1
- package/dist/src/internals/CommandInteraction.js +10 -4
- package/dist/src/internals/CommandInteraction.js.map +1 -1
- package/dist/src/internals/ComponentHandler.d.ts +5 -2
- package/dist/src/internals/ComponentHandler.d.ts.map +1 -1
- package/dist/src/internals/ComponentHandler.js +34 -10
- package/dist/src/internals/ComponentHandler.js.map +1 -1
- package/dist/src/internals/ModalHandler.d.ts +1 -1
- package/dist/src/internals/ModalHandler.d.ts.map +1 -1
- package/dist/src/internals/ModalHandler.js +6 -2
- package/dist/src/internals/ModalHandler.js.map +1 -1
- package/dist/src/internals/ModalInteraction.js +1 -1
- package/dist/src/internals/ModalInteraction.js.map +1 -1
- package/dist/src/internals/OptionsHandler.d.ts +13 -3
- package/dist/src/internals/OptionsHandler.d.ts.map +1 -1
- package/dist/src/internals/OptionsHandler.js +51 -1
- package/dist/src/internals/OptionsHandler.js.map +1 -1
- package/dist/src/permissions.d.ts +54 -0
- package/dist/src/permissions.d.ts.map +1 -0
- package/dist/src/permissions.js +4 -0
- package/dist/src/permissions.js.map +1 -0
- package/dist/src/plugins/command-data/CommandDataPlugin.d.ts +16 -0
- package/dist/src/plugins/command-data/CommandDataPlugin.d.ts.map +1 -0
- package/dist/src/plugins/command-data/CommandDataPlugin.js +46 -0
- package/dist/src/plugins/command-data/CommandDataPlugin.js.map +1 -0
- package/dist/src/plugins/command-data/index.d.ts +2 -0
- package/dist/src/plugins/command-data/index.d.ts.map +1 -0
- package/dist/src/plugins/command-data/index.js +2 -0
- package/dist/src/plugins/command-data/index.js.map +1 -0
- package/dist/src/plugins/gateway/GatewayPlugin.d.ts +47 -3
- package/dist/src/plugins/gateway/GatewayPlugin.d.ts.map +1 -1
- package/dist/src/plugins/gateway/GatewayPlugin.js +169 -22
- package/dist/src/plugins/gateway/GatewayPlugin.js.map +1 -1
- package/dist/src/plugins/gateway/types.d.ts +58 -0
- package/dist/src/plugins/gateway/types.d.ts.map +1 -1
- package/dist/src/plugins/gateway/types.js.map +1 -1
- package/dist/src/plugins/gateway/utils/monitor.d.ts +2 -0
- package/dist/src/plugins/gateway/utils/monitor.d.ts.map +1 -1
- package/dist/src/plugins/gateway/utils/monitor.js +10 -1
- package/dist/src/plugins/gateway/utils/monitor.js.map +1 -1
- package/dist/src/plugins/gateway/utils/payload.d.ts +8 -5
- package/dist/src/plugins/gateway/utils/payload.d.ts.map +1 -1
- package/dist/src/plugins/gateway/utils/payload.js +20 -1
- package/dist/src/plugins/gateway/utils/payload.js.map +1 -1
- package/dist/src/plugins/gateway/utils/rateLimit.d.ts +41 -0
- package/dist/src/plugins/gateway/utils/rateLimit.d.ts.map +1 -0
- package/dist/src/plugins/gateway/utils/rateLimit.js +61 -0
- package/dist/src/plugins/gateway/utils/rateLimit.js.map +1 -0
- package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.d.ts +1 -1
- package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.d.ts.map +1 -1
- package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.js +2 -2
- package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.js.map +1 -1
- package/dist/src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.d.ts +10 -0
- package/dist/src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.d.ts.map +1 -0
- package/dist/src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.js +11 -0
- package/dist/src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.js.map +1 -0
- package/dist/src/plugins/gateway-forwarder/index.d.ts +1 -0
- package/dist/src/plugins/gateway-forwarder/index.d.ts.map +1 -1
- package/dist/src/plugins/gateway-forwarder/index.js +1 -0
- package/dist/src/plugins/gateway-forwarder/index.js.map +1 -1
- package/dist/src/plugins/paginator/GoToPageModal.d.ts +24 -0
- package/dist/src/plugins/paginator/GoToPageModal.d.ts.map +1 -0
- package/dist/src/plugins/paginator/GoToPageModal.js +50 -0
- package/dist/src/plugins/paginator/GoToPageModal.js.map +1 -0
- package/dist/src/plugins/paginator/Paginator.d.ts +53 -0
- package/dist/src/plugins/paginator/Paginator.d.ts.map +1 -0
- package/dist/src/plugins/paginator/Paginator.js +183 -0
- package/dist/src/plugins/paginator/Paginator.js.map +1 -0
- package/dist/src/plugins/paginator/index.d.ts +9 -0
- package/dist/src/plugins/paginator/index.d.ts.map +1 -0
- package/dist/src/plugins/paginator/index.js +9 -0
- package/dist/src/plugins/paginator/index.js.map +1 -0
- package/dist/src/plugins/sharding/ShardingPlugin.d.ts +3 -1
- package/dist/src/plugins/sharding/ShardingPlugin.d.ts.map +1 -1
- package/dist/src/plugins/sharding/ShardingPlugin.js +11 -2
- package/dist/src/plugins/sharding/ShardingPlugin.js.map +1 -1
- package/dist/src/structures/DmChannel.d.ts +3 -3
- package/dist/src/structures/DmChannel.d.ts.map +1 -1
- package/dist/src/structures/DmChannel.js +5 -3
- package/dist/src/structures/DmChannel.js.map +1 -1
- package/dist/src/structures/GroupDmChannel.d.ts +1 -1
- package/dist/src/structures/GroupDmChannel.d.ts.map +1 -1
- package/dist/src/structures/Guild.d.ts +184 -5
- package/dist/src/structures/Guild.d.ts.map +1 -1
- package/dist/src/structures/Guild.js +406 -12
- package/dist/src/structures/Guild.js.map +1 -1
- package/dist/src/structures/GuildCategoryChannel.d.ts +1 -1
- package/dist/src/structures/GuildCategoryChannel.d.ts.map +1 -1
- package/dist/src/structures/GuildForumChannel.d.ts +1 -1
- package/dist/src/structures/GuildForumChannel.d.ts.map +1 -1
- package/dist/src/structures/GuildMember.d.ts +15 -12
- package/dist/src/structures/GuildMember.d.ts.map +1 -1
- package/dist/src/structures/GuildMember.js +78 -19
- package/dist/src/structures/GuildMember.js.map +1 -1
- package/dist/src/structures/GuildStageOrVoiceChannel.d.ts +1 -1
- package/dist/src/structures/GuildStageOrVoiceChannel.d.ts.map +1 -1
- package/dist/src/structures/GuildTextChannel.d.ts +1 -1
- package/dist/src/structures/GuildTextChannel.d.ts.map +1 -1
- package/dist/src/structures/GuildThreadChannel.d.ts +1 -1
- package/dist/src/structures/GuildThreadChannel.d.ts.map +1 -1
- package/dist/src/structures/Message.d.ts +29 -10
- package/dist/src/structures/Message.d.ts.map +1 -1
- package/dist/src/structures/Message.js +82 -18
- package/dist/src/structures/Message.js.map +1 -1
- package/dist/src/structures/Poll.d.ts +25 -0
- package/dist/src/structures/Poll.d.ts.map +1 -0
- package/dist/src/structures/Poll.js +45 -0
- package/dist/src/structures/Poll.js.map +1 -0
- package/dist/src/structures/Role.d.ts +29 -12
- package/dist/src/structures/Role.d.ts.map +1 -1
- package/dist/src/structures/Role.js +48 -21
- package/dist/src/structures/Role.js.map +1 -1
- package/dist/src/structures/ThreadMember.d.ts +36 -0
- package/dist/src/structures/ThreadMember.d.ts.map +1 -0
- package/dist/src/structures/ThreadMember.js +72 -0
- package/dist/src/structures/ThreadMember.js.map +1 -0
- package/dist/src/structures/User.d.ts +7 -2
- package/dist/src/structures/User.d.ts.map +1 -1
- package/dist/src/structures/User.js +8 -1
- package/dist/src/structures/User.js.map +1 -1
- package/dist/src/structures/Webhook.d.ts +135 -0
- package/dist/src/structures/Webhook.d.ts.map +1 -0
- package/dist/src/structures/Webhook.js +239 -0
- package/dist/src/structures/Webhook.js.map +1 -0
- package/dist/src/types/index.d.ts +73 -8
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/listeners.d.ts +71 -44
- package/dist/src/types/listeners.d.ts.map +1 -1
- package/dist/src/types/listeners.js.map +1 -1
- package/dist/src/utils/customIdParser.d.ts +3 -0
- package/dist/src/utils/customIdParser.d.ts.map +1 -0
- package/dist/src/utils/customIdParser.js +17 -0
- package/dist/src/utils/customIdParser.js.map +1 -0
- package/dist/src/utils/index.d.ts +4 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/index.js +4 -0
- package/dist/src/utils/index.js.map +1 -0
- package/dist/src/utils/payload.d.ts +4 -0
- package/dist/src/utils/payload.d.ts.map +1 -0
- package/dist/src/utils/payload.js +45 -0
- package/dist/src/utils/payload.js.map +1 -0
- package/dist/src/utils/verification.d.ts +4 -0
- package/dist/src/utils/verification.d.ts.map +1 -0
- package/dist/src/utils/verification.js +52 -0
- package/dist/src/utils/verification.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/dist/src/utils.d.ts +0 -9
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/src/utils.js +0 -93
- package/dist/src/utils.js.map +0 -1
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { APIWebhook, RESTPatchAPIWebhookJSONBody, WebhookType } from "discord-api-types/v10";
|
|
2
|
+
import { Base } from "../abstracts/Base.js";
|
|
3
|
+
import type { Client } from "../classes/Client.js";
|
|
4
|
+
import type { IfPartial, MessagePayload } from "../types/index.js";
|
|
5
|
+
import { Message } from "./Message.js";
|
|
6
|
+
import { User } from "./User.js";
|
|
7
|
+
export type WebhookInput = APIWebhook | {
|
|
8
|
+
id: string;
|
|
9
|
+
token: string;
|
|
10
|
+
threadId?: string;
|
|
11
|
+
} | string;
|
|
12
|
+
export declare class Webhook<IsPartial extends boolean = false> extends Base {
|
|
13
|
+
constructor(client: Client, rawData: APIWebhook);
|
|
14
|
+
constructor(client: Client, idAndToken: {
|
|
15
|
+
id: string;
|
|
16
|
+
token: string;
|
|
17
|
+
threadId?: string;
|
|
18
|
+
});
|
|
19
|
+
constructor(client: Client, url: string);
|
|
20
|
+
constructor(client: Client, input: WebhookInput);
|
|
21
|
+
protected rawData: APIWebhook | null;
|
|
22
|
+
private setData;
|
|
23
|
+
/**
|
|
24
|
+
* The ID of the webhook
|
|
25
|
+
*/
|
|
26
|
+
readonly id: string;
|
|
27
|
+
/**
|
|
28
|
+
* The token of the webhook
|
|
29
|
+
*/
|
|
30
|
+
readonly token?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The thread ID this webhook is for
|
|
33
|
+
*/
|
|
34
|
+
readonly threadId?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Whether the webhook is a partial webhook (meaning it does not have all the data).
|
|
37
|
+
* If this is true, you should use {@link Webhook.fetch} to get the full data of the webhook.
|
|
38
|
+
*/
|
|
39
|
+
get partial(): IsPartial;
|
|
40
|
+
/**
|
|
41
|
+
* The type of the webhook
|
|
42
|
+
* @see https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types
|
|
43
|
+
*/
|
|
44
|
+
get type(): IfPartial<IsPartial, WebhookType>;
|
|
45
|
+
/**
|
|
46
|
+
* The guild id this webhook is for
|
|
47
|
+
*/
|
|
48
|
+
get guildId(): IfPartial<IsPartial, string | undefined>;
|
|
49
|
+
/**
|
|
50
|
+
* The channel id this webhook is for
|
|
51
|
+
*/
|
|
52
|
+
get channelId(): IfPartial<IsPartial, string>;
|
|
53
|
+
/**
|
|
54
|
+
* The user this webhook was created by
|
|
55
|
+
* Not returned when getting a webhook with its token
|
|
56
|
+
*/
|
|
57
|
+
get user(): IfPartial<IsPartial, User | undefined>;
|
|
58
|
+
/**
|
|
59
|
+
* The default name of the webhook
|
|
60
|
+
*/
|
|
61
|
+
get name(): IfPartial<IsPartial, string | null>;
|
|
62
|
+
/**
|
|
63
|
+
* The default avatar of the webhook
|
|
64
|
+
*/
|
|
65
|
+
get avatar(): IfPartial<IsPartial, string | null>;
|
|
66
|
+
/**
|
|
67
|
+
* Get the URL of the webhook's avatar
|
|
68
|
+
*/
|
|
69
|
+
get avatarUrl(): IfPartial<IsPartial, string | null>;
|
|
70
|
+
/**
|
|
71
|
+
* The bot/OAuth2 application that created this webhook
|
|
72
|
+
*/
|
|
73
|
+
get applicationId(): IfPartial<IsPartial, string | null>;
|
|
74
|
+
/**
|
|
75
|
+
* The guild of the channel that this webhook is following
|
|
76
|
+
* Only returned for Channel Follower Webhooks
|
|
77
|
+
*/
|
|
78
|
+
get sourceGuild(): IfPartial<IsPartial, APIWebhook["source_guild"] | undefined>;
|
|
79
|
+
/**
|
|
80
|
+
* The channel that this webhook is following
|
|
81
|
+
* Only returned for Channel Follower Webhooks
|
|
82
|
+
*/
|
|
83
|
+
get sourceChannel(): IfPartial<IsPartial, APIWebhook["source_channel"] | undefined>;
|
|
84
|
+
/**
|
|
85
|
+
* The url used for executing the webhook
|
|
86
|
+
* Only returned by the webhooks OAuth2 flow
|
|
87
|
+
*/
|
|
88
|
+
get url(): IfPartial<IsPartial, string | undefined>;
|
|
89
|
+
/**
|
|
90
|
+
* Fetch this webhook's data
|
|
91
|
+
* @returns A Promise that resolves to a non-partial Webhook
|
|
92
|
+
*/
|
|
93
|
+
fetch(): Promise<Webhook<false>>;
|
|
94
|
+
/**
|
|
95
|
+
* Modify this webhook
|
|
96
|
+
* @param data The data to modify the webhook with
|
|
97
|
+
* @returns A Promise that resolves to the modified webhook
|
|
98
|
+
*/
|
|
99
|
+
modify(data: RESTPatchAPIWebhookJSONBody): Promise<Webhook<false>>;
|
|
100
|
+
/**
|
|
101
|
+
* Delete this webhook
|
|
102
|
+
* @returns A Promise that resolves when the webhook is deleted
|
|
103
|
+
*/
|
|
104
|
+
delete(): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Send a message through this webhook
|
|
107
|
+
* @param data The data to send with the webhook
|
|
108
|
+
* @param threadId Optional ID of the thread to send the message to. If not provided, uses the webhook's thread ID.
|
|
109
|
+
* @returns A Promise that resolves to the created message
|
|
110
|
+
*/
|
|
111
|
+
send(data: MessagePayload, threadId?: string): Promise<Message>;
|
|
112
|
+
/**
|
|
113
|
+
* Edit a message sent by this webhook
|
|
114
|
+
* @param messageId The ID of the message to edit
|
|
115
|
+
* @param data The data to edit the message with
|
|
116
|
+
* @param threadId Optional ID of the thread to edit the message in. If not provided, uses the webhook's thread ID.
|
|
117
|
+
* @returns A Promise that resolves to the edited message
|
|
118
|
+
*/
|
|
119
|
+
edit(messageId: string, data: MessagePayload, threadId?: string): Promise<Message>;
|
|
120
|
+
/**
|
|
121
|
+
* Delete a message sent by this webhook
|
|
122
|
+
* @param messageId The ID of the message to delete
|
|
123
|
+
* @param threadId Optional ID of the thread to delete the message from. If not provided, uses the webhook's thread ID.
|
|
124
|
+
* @returns A Promise that resolves when the message is deleted
|
|
125
|
+
*/
|
|
126
|
+
deleteMessage(messageId: string, threadId?: string): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Get a message sent by this webhook
|
|
129
|
+
* @param messageId The ID of the message to get
|
|
130
|
+
* @param threadId Optional ID of the thread to get the message from. If not provided, uses the webhook's thread ID.
|
|
131
|
+
* @returns A Promise that resolves to the message
|
|
132
|
+
*/
|
|
133
|
+
getMessage(messageId: string, threadId?: string): Promise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OAIG;IACG,MAAM,CAAC,IAAI,EAAE,2BAA2B,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAUxE;;;OAGG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B;;;;;OAKG;IACG,IAAI,CAAC,IAAI,EAAE,cAAc,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAiBrE;;;;;;OAMG;IACG,IAAI,CACT,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,cAAc,EACpB,QAAQ,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC;IAiBnB;;;;;OAKG;IACG,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYxE;;;;;OAKG;IACG,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAWxE"}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { Routes } from "discord-api-types/v10";
|
|
2
|
+
import { Base } from "../abstracts/Base.js";
|
|
3
|
+
import { serializePayload } from "../utils/index.js";
|
|
4
|
+
import { Message } from "./Message.js";
|
|
5
|
+
import { User } from "./User.js";
|
|
6
|
+
export class Webhook extends Base {
|
|
7
|
+
constructor(client, input) {
|
|
8
|
+
super(client);
|
|
9
|
+
if (typeof input === "string") {
|
|
10
|
+
const url = new URL(input);
|
|
11
|
+
if (url.protocol !== "https:")
|
|
12
|
+
throw new Error("Invalid URL");
|
|
13
|
+
const [id, token] = url.pathname.split("/").slice(2);
|
|
14
|
+
if (!id || !token)
|
|
15
|
+
throw new Error("Invalid URL");
|
|
16
|
+
this.id = id;
|
|
17
|
+
this.token = token;
|
|
18
|
+
const potentialThreadId = url.searchParams.get("thread_id");
|
|
19
|
+
this.threadId = potentialThreadId ?? undefined;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
if ("channel_id" in input) {
|
|
23
|
+
this.setData(input);
|
|
24
|
+
}
|
|
25
|
+
this.id = input.id;
|
|
26
|
+
this.token = input.token;
|
|
27
|
+
this.threadId = "threadId" in input ? input.threadId : undefined;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
rawData = null;
|
|
31
|
+
setData(data) {
|
|
32
|
+
if (!data)
|
|
33
|
+
throw new Error("Cannot set data without having data... smh");
|
|
34
|
+
this.rawData = data;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The ID of the webhook
|
|
38
|
+
*/
|
|
39
|
+
id;
|
|
40
|
+
/**
|
|
41
|
+
* The token of the webhook
|
|
42
|
+
*/
|
|
43
|
+
token;
|
|
44
|
+
/**
|
|
45
|
+
* The thread ID this webhook is for
|
|
46
|
+
*/
|
|
47
|
+
threadId;
|
|
48
|
+
/**
|
|
49
|
+
* Whether the webhook is a partial webhook (meaning it does not have all the data).
|
|
50
|
+
* If this is true, you should use {@link Webhook.fetch} to get the full data of the webhook.
|
|
51
|
+
*/
|
|
52
|
+
get partial() {
|
|
53
|
+
return (this.rawData === null);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The type of the webhook
|
|
57
|
+
* @see https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types
|
|
58
|
+
*/
|
|
59
|
+
get type() {
|
|
60
|
+
if (!this.rawData)
|
|
61
|
+
return undefined;
|
|
62
|
+
return this.rawData.type;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The guild id this webhook is for
|
|
66
|
+
*/
|
|
67
|
+
get guildId() {
|
|
68
|
+
if (!this.rawData)
|
|
69
|
+
return undefined;
|
|
70
|
+
return this.rawData.guild_id;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The channel id this webhook is for
|
|
74
|
+
*/
|
|
75
|
+
get channelId() {
|
|
76
|
+
if (!this.rawData)
|
|
77
|
+
return undefined;
|
|
78
|
+
return this.rawData.channel_id;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The user this webhook was created by
|
|
82
|
+
* Not returned when getting a webhook with its token
|
|
83
|
+
*/
|
|
84
|
+
get user() {
|
|
85
|
+
if (!this.rawData?.user)
|
|
86
|
+
return undefined;
|
|
87
|
+
return new User(this.client, this.rawData.user);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The default name of the webhook
|
|
91
|
+
*/
|
|
92
|
+
get name() {
|
|
93
|
+
if (!this.rawData)
|
|
94
|
+
return undefined;
|
|
95
|
+
return this.rawData.name;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The default avatar of the webhook
|
|
99
|
+
*/
|
|
100
|
+
get avatar() {
|
|
101
|
+
if (!this.rawData)
|
|
102
|
+
return undefined;
|
|
103
|
+
return this.rawData.avatar;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Get the URL of the webhook's avatar
|
|
107
|
+
*/
|
|
108
|
+
get avatarUrl() {
|
|
109
|
+
if (!this.rawData)
|
|
110
|
+
return undefined;
|
|
111
|
+
if (!this.avatar)
|
|
112
|
+
return null;
|
|
113
|
+
return `https://cdn.discordapp.com/avatars/${this.id}/${this.avatar}.png`;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The bot/OAuth2 application that created this webhook
|
|
117
|
+
*/
|
|
118
|
+
get applicationId() {
|
|
119
|
+
if (!this.rawData)
|
|
120
|
+
return undefined;
|
|
121
|
+
return this.rawData.application_id;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* The guild of the channel that this webhook is following
|
|
125
|
+
* Only returned for Channel Follower Webhooks
|
|
126
|
+
*/
|
|
127
|
+
get sourceGuild() {
|
|
128
|
+
if (!this.rawData)
|
|
129
|
+
return undefined;
|
|
130
|
+
return this.rawData.source_guild;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The channel that this webhook is following
|
|
134
|
+
* Only returned for Channel Follower Webhooks
|
|
135
|
+
*/
|
|
136
|
+
get sourceChannel() {
|
|
137
|
+
if (!this.rawData)
|
|
138
|
+
return undefined;
|
|
139
|
+
return this.rawData.source_channel;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* The url used for executing the webhook
|
|
143
|
+
* Only returned by the webhooks OAuth2 flow
|
|
144
|
+
*/
|
|
145
|
+
get url() {
|
|
146
|
+
if (!this.rawData)
|
|
147
|
+
return undefined;
|
|
148
|
+
return this.rawData.url;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Fetch this webhook's data
|
|
152
|
+
* @returns A Promise that resolves to a non-partial Webhook
|
|
153
|
+
*/
|
|
154
|
+
async fetch() {
|
|
155
|
+
const newData = (await this.client.rest.get(Routes.webhook(this.id)));
|
|
156
|
+
if (!newData)
|
|
157
|
+
throw new Error(`Webhook ${this.id} not found`);
|
|
158
|
+
this.setData(newData);
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Modify this webhook
|
|
163
|
+
* @param data The data to modify the webhook with
|
|
164
|
+
* @returns A Promise that resolves to the modified webhook
|
|
165
|
+
*/
|
|
166
|
+
async modify(data) {
|
|
167
|
+
const newData = (await this.client.rest.patch(Routes.webhook(this.id), {
|
|
168
|
+
body: data
|
|
169
|
+
}));
|
|
170
|
+
this.setData(newData);
|
|
171
|
+
return this;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Delete this webhook
|
|
175
|
+
* @returns A Promise that resolves when the webhook is deleted
|
|
176
|
+
*/
|
|
177
|
+
async delete() {
|
|
178
|
+
await this.client.rest.delete(Routes.webhook(this.id));
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Send a message through this webhook
|
|
182
|
+
* @param data The data to send with the webhook
|
|
183
|
+
* @param threadId Optional ID of the thread to send the message to. If not provided, uses the webhook's thread ID.
|
|
184
|
+
* @returns A Promise that resolves to the created message
|
|
185
|
+
*/
|
|
186
|
+
async send(data, threadId) {
|
|
187
|
+
if (!this.token)
|
|
188
|
+
throw new Error("Cannot send webhook message without token");
|
|
189
|
+
const serialized = serializePayload(data);
|
|
190
|
+
const finalThreadId = threadId || this.threadId;
|
|
191
|
+
const message = (await this.client.rest.post(Routes.webhook(this.id, this.token), {
|
|
192
|
+
body: serialized
|
|
193
|
+
}, finalThreadId ? { thread_id: finalThreadId } : undefined));
|
|
194
|
+
return new Message(this.client, message);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Edit a message sent by this webhook
|
|
198
|
+
* @param messageId The ID of the message to edit
|
|
199
|
+
* @param data The data to edit the message with
|
|
200
|
+
* @param threadId Optional ID of the thread to edit the message in. If not provided, uses the webhook's thread ID.
|
|
201
|
+
* @returns A Promise that resolves to the edited message
|
|
202
|
+
*/
|
|
203
|
+
async edit(messageId, data, threadId) {
|
|
204
|
+
if (!this.token)
|
|
205
|
+
throw new Error("Cannot edit webhook message without token");
|
|
206
|
+
const serialized = serializePayload(data);
|
|
207
|
+
const finalThreadId = threadId || this.threadId;
|
|
208
|
+
const message = (await this.client.rest.patch(Routes.webhookMessage(this.id, this.token, messageId), {
|
|
209
|
+
body: serialized
|
|
210
|
+
}, finalThreadId ? { thread_id: finalThreadId } : undefined));
|
|
211
|
+
return new Message(this.client, message);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Delete a message sent by this webhook
|
|
215
|
+
* @param messageId The ID of the message to delete
|
|
216
|
+
* @param threadId Optional ID of the thread to delete the message from. If not provided, uses the webhook's thread ID.
|
|
217
|
+
* @returns A Promise that resolves when the message is deleted
|
|
218
|
+
*/
|
|
219
|
+
async deleteMessage(messageId, threadId) {
|
|
220
|
+
if (!this.token)
|
|
221
|
+
throw new Error("Cannot delete webhook message without token");
|
|
222
|
+
const finalThreadId = threadId || this.threadId;
|
|
223
|
+
await this.client.rest.delete(Routes.webhookMessage(this.id, this.token, messageId), undefined, finalThreadId ? { thread_id: finalThreadId } : undefined);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Get a message sent by this webhook
|
|
227
|
+
* @param messageId The ID of the message to get
|
|
228
|
+
* @param threadId Optional ID of the thread to get the message from. If not provided, uses the webhook's thread ID.
|
|
229
|
+
* @returns A Promise that resolves to the message
|
|
230
|
+
*/
|
|
231
|
+
async getMessage(messageId, threadId) {
|
|
232
|
+
if (!this.token)
|
|
233
|
+
throw new Error("Cannot get webhook message without token");
|
|
234
|
+
const finalThreadId = threadId || this.threadId;
|
|
235
|
+
const message = (await this.client.rest.get(Routes.webhookMessage(this.id, this.token, messageId), finalThreadId ? { thread_id: finalThreadId } : undefined));
|
|
236
|
+
return new Message(this.client, message);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=Webhook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Webhook.js","sourceRoot":"","sources":["../../../src/structures/Webhook.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAG3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAOhC,MAAM,OAAO,OAA2C,SAAQ,IAAI;IAYnE,YAAY,MAAc,EAAE,KAAmB;QAC9C,KAAK,CAAC,MAAM,CAAC,CAAA;QACb,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC/B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAA;YAC1B,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ;gBAAE,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAA;YAC7D,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,GAAG,GA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AAO,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACzC,CAAC;CACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { APIAllowedMentions } from "discord-api-types/v10";
|
|
1
|
+
import type { APIAllowedMentions, APIAttachment } from "discord-api-types/v10";
|
|
2
2
|
import type { BaseMessageInteractiveComponent } from "../abstracts/BaseMessageInteractiveComponent.js";
|
|
3
3
|
import type { Embed } from "../classes/Embed.js";
|
|
4
4
|
import type { Container } from "../classes/components/Container.js";
|
|
@@ -8,13 +8,53 @@ import type { Row } from "../classes/components/Row.js";
|
|
|
8
8
|
import type { Section } from "../classes/components/Section.js";
|
|
9
9
|
import type { Separator } from "../classes/components/Separator.js";
|
|
10
10
|
import type { TextDisplay } from "../classes/components/TextDisplay.js";
|
|
11
|
+
export type ComponentParserResult = {
|
|
12
|
+
key: string;
|
|
13
|
+
data: Record<string, string | number | boolean>;
|
|
14
|
+
};
|
|
15
|
+
export type ComponentData<T extends keyof ComponentParserResult["data"] = keyof ComponentParserResult["data"]> = {
|
|
16
|
+
[K in T]: ComponentParserResult["data"][K];
|
|
17
|
+
};
|
|
11
18
|
export type AllowedMentions = APIAllowedMentions;
|
|
12
19
|
export type TopLevelComponents = Row<BaseMessageInteractiveComponent> | Container | File | MediaGallery | Section | Separator | TextDisplay;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
export type PollSendPayload = {
|
|
21
|
+
question: {
|
|
22
|
+
/**
|
|
23
|
+
* The text of the question, up to 300 characters
|
|
24
|
+
*/
|
|
25
|
+
text?: string;
|
|
26
|
+
};
|
|
27
|
+
answers: {
|
|
28
|
+
/**
|
|
29
|
+
* The text of the answer, up to 55 characters
|
|
30
|
+
*/
|
|
31
|
+
text?: string;
|
|
32
|
+
/**
|
|
33
|
+
* The emoji of the answer.
|
|
34
|
+
* When creating a poll answer with an emoji,
|
|
35
|
+
* you only need to send either the id (custom emoji) or name (default emoji) as the only field.
|
|
36
|
+
*/
|
|
37
|
+
emoji?: {
|
|
38
|
+
name: string;
|
|
39
|
+
id: string;
|
|
40
|
+
};
|
|
41
|
+
}[];
|
|
42
|
+
/**
|
|
43
|
+
* The time in seconds before the poll expires.
|
|
44
|
+
*/
|
|
45
|
+
expiry: number;
|
|
46
|
+
/**
|
|
47
|
+
* Whether the poll allows multiple answers
|
|
48
|
+
*/
|
|
49
|
+
allowMultiselect: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* The layout type of the poll.
|
|
52
|
+
* Currently only 1 is supported, and will be set by default.
|
|
53
|
+
* @default 1
|
|
54
|
+
*/
|
|
55
|
+
layoutType?: 1;
|
|
56
|
+
};
|
|
57
|
+
export type MessagePayloadObject = {
|
|
18
58
|
/**
|
|
19
59
|
* The content of the message
|
|
20
60
|
*/
|
|
@@ -43,7 +83,16 @@ export type MessagePayload = {
|
|
|
43
83
|
* The files to send in the message
|
|
44
84
|
*/
|
|
45
85
|
files?: MessagePayloadFile[];
|
|
46
|
-
|
|
86
|
+
/**
|
|
87
|
+
* The poll to send in the message
|
|
88
|
+
*/
|
|
89
|
+
poll?: PollSendPayload;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* The data that is sent to Discord when sending a message.
|
|
93
|
+
* If you pass just a string, it will be treated as the content of the message.
|
|
94
|
+
*/
|
|
95
|
+
export type MessagePayload = string | MessagePayloadObject;
|
|
47
96
|
/**
|
|
48
97
|
* The data for a file to send in an interaction
|
|
49
98
|
*/
|
|
@@ -58,10 +107,26 @@ export type MessagePayloadFile = {
|
|
|
58
107
|
data: Blob;
|
|
59
108
|
/**
|
|
60
109
|
* The alt text of the file, shown for accessibility
|
|
61
|
-
* @alpha This isn't implemented yet
|
|
62
110
|
*/
|
|
63
111
|
description?: string;
|
|
64
112
|
};
|
|
113
|
+
export type VoiceState = {
|
|
114
|
+
guildId?: string;
|
|
115
|
+
channelId: string | null;
|
|
116
|
+
userId: string;
|
|
117
|
+
sessionId: string;
|
|
118
|
+
deaf: boolean;
|
|
119
|
+
mute: boolean;
|
|
120
|
+
selfDeaf: boolean;
|
|
121
|
+
selfMute: boolean;
|
|
122
|
+
selfStream: boolean;
|
|
123
|
+
selfVideo: boolean;
|
|
124
|
+
suppress: boolean;
|
|
125
|
+
requestToSpeakTimestamp: string | null;
|
|
126
|
+
};
|
|
127
|
+
export type ResolvedFile = APIAttachment;
|
|
128
|
+
export type BaseMessageInteractiveComponentConstructor = new (...args: any[]) => BaseMessageInteractiveComponent;
|
|
65
129
|
export type ArrayOrSingle<T> = T | T[];
|
|
130
|
+
export type IfPartial<T, U, V = U | undefined> = T extends true ? V : U;
|
|
66
131
|
export * from "./listeners.js";
|
|
67
132
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC9E,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,iDAAiD,CAAA;AACtG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAA;AACnE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAA;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAA;AACzE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,8BAA8B,CAAA;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAA;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oC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,CAAC,GAAG,SAAS,IAAI,CAAC,SAAS,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;AAEvE,cAAc,gBAAgB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAwJA,cAAc,gBAAgB,CAAA"}
|