@buape/carbon 0.8.0 → 0.9.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 +6 -6
- 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 +1 -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 +4 -3
- package/dist/src/abstracts/GuildThreadOnlyChannel.d.ts.map +1 -1
- package/dist/src/abstracts/GuildThreadOnlyChannel.js +1 -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 +27 -6
- package/dist/src/classes/Client.d.ts.map +1 -1
- package/dist/src/classes/Client.js +62 -14
- package/dist/src/classes/Client.js.map +1 -1
- 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 +5 -54
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -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/CommandHandler.d.ts +1 -1
- package/dist/src/internals/CommandHandler.d.ts.map +1 -1
- package/dist/src/internals/CommandHandler.js +25 -3
- 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 +1 -1
- package/dist/src/plugins/gateway/GatewayPlugin.d.ts.map +1 -1
- package/dist/src/plugins/gateway/GatewayPlugin.js +49 -16
- package/dist/src/plugins/gateway/GatewayPlugin.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 +1 -0
- package/dist/src/plugins/gateway/utils/payload.d.ts.map +1 -1
- package/dist/src/plugins/gateway/utils/payload.js +2 -1
- package/dist/src/plugins/gateway/utils/payload.js.map +1 -1
- 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 +9 -0
- package/dist/src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.d.ts.map +1 -0
- package/dist/src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.js +10 -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/Paginator.d.ts +51 -0
- package/dist/src/plugins/paginator/Paginator.d.ts.map +1 -0
- package/dist/src/plugins/paginator/Paginator.js +155 -0
- package/dist/src/plugins/paginator/Paginator.js.map +1 -0
- package/dist/src/plugins/paginator/index.d.ts +8 -0
- package/dist/src/plugins/paginator/index.d.ts.map +1 -0
- package/dist/src/plugins/paginator/index.js +8 -0
- package/dist/src/plugins/paginator/index.js.map +1 -0
- package/dist/src/plugins/sharding/ShardingPlugin.d.ts +1 -0
- package/dist/src/plugins/sharding/ShardingPlugin.d.ts.map +1 -1
- package/dist/src/plugins/sharding/ShardingPlugin.js +2 -1
- 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 +26 -7
- package/dist/src/structures/Message.d.ts.map +1 -1
- package/dist/src/structures/Message.js +72 -12
- 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 +6 -6
- 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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InteractionResponseType, MessageFlags, Routes } from "discord-api-types/v10";
|
|
2
|
-
import { Embed, Guild, Message, User, channelFactory } from "../index.js";
|
|
2
|
+
import { BaseMessageInteractiveComponent, Container, Embed, Guild, Message, Row, Section, User, channelFactory } from "../index.js";
|
|
3
3
|
import { GuildMember } from "../structures/GuildMember.js";
|
|
4
|
-
import { serializePayload } from "../utils.js";
|
|
4
|
+
import { serializePayload } from "../utils/index.js";
|
|
5
5
|
import { Base } from "./Base.js";
|
|
6
6
|
/**
|
|
7
7
|
* This is the base type interaction, all interaction types extend from this
|
|
@@ -68,26 +68,73 @@ export class BaseInteraction extends Base {
|
|
|
68
68
|
return null;
|
|
69
69
|
return new GuildMember(this.client, this.rawData.member, this.guild);
|
|
70
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* @internal
|
|
73
|
+
* Automatically register components found in a message payload when sending the message.
|
|
74
|
+
*/
|
|
75
|
+
_internalAutoRegisterComponentsOnSend(data) {
|
|
76
|
+
if (typeof data !== "string" && data.components) {
|
|
77
|
+
this._internalRegisterComponentsOnSend(data.components);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* @internal
|
|
82
|
+
* Register components found in a message payload when sending the message.
|
|
83
|
+
*/
|
|
84
|
+
_internalRegisterComponentsOnSend(components) {
|
|
85
|
+
for (const component of components) {
|
|
86
|
+
if (component instanceof Row) {
|
|
87
|
+
for (const childComponent of component.components) {
|
|
88
|
+
if (childComponent instanceof BaseMessageInteractiveComponent) {
|
|
89
|
+
const key = childComponent.customIdParser(childComponent.customId).key;
|
|
90
|
+
const existingComponent = this.client.componentHandler.components.find((comp) => comp.customIdParser(comp.customId).key === key);
|
|
91
|
+
if (!existingComponent) {
|
|
92
|
+
this.client.componentHandler.registerComponent(childComponent);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else if (component instanceof Section) {
|
|
98
|
+
if (component.accessory instanceof BaseMessageInteractiveComponent) {
|
|
99
|
+
const key = component.accessory.customIdParser(component.accessory.customId).key;
|
|
100
|
+
const existingComponent = this.client.componentHandler.components.find((comp) => comp.customIdParser(comp.customId).key === key);
|
|
101
|
+
if (!existingComponent) {
|
|
102
|
+
this.client.componentHandler.registerComponent(component.accessory);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else if (component instanceof Container) {
|
|
107
|
+
this._internalRegisterComponentsOnSend(component.components);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
71
111
|
/**
|
|
72
112
|
* Reply to an interaction.
|
|
73
113
|
* If the interaction is deferred, this will edit the original response.
|
|
74
|
-
* @param data The
|
|
114
|
+
* @param data The message data to send
|
|
75
115
|
*/
|
|
76
|
-
async reply(data) {
|
|
116
|
+
async reply(data, overrideAutoRegister = false) {
|
|
77
117
|
const serialized = serializePayload(data, this.defaultEphemeral);
|
|
118
|
+
// Auto-register any components in the message
|
|
119
|
+
if (!overrideAutoRegister)
|
|
120
|
+
this._internalAutoRegisterComponentsOnSend(data);
|
|
78
121
|
if (this._deferred) {
|
|
79
|
-
await this.client.rest.patch(Routes.webhookMessage(this.client.options.clientId, this.rawData.token, "@original"), {
|
|
122
|
+
const message = (await this.client.rest.patch(Routes.webhookMessage(this.client.options.clientId, this.rawData.token, "@original"), {
|
|
80
123
|
body: serialized
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
else {
|
|
84
|
-
await this.client.rest.post(Routes.interactionCallback(this.rawData.id, this.rawData.token), {
|
|
85
|
-
body: {
|
|
86
|
-
type: InteractionResponseType.ChannelMessageWithSource,
|
|
87
|
-
data: serialized
|
|
88
|
-
}
|
|
89
|
-
});
|
|
124
|
+
}));
|
|
125
|
+
return new Message(this.client, message);
|
|
90
126
|
}
|
|
127
|
+
const done = (await this.client.rest.post(Routes.interactionCallback(this.rawData.id, this.rawData.token), {
|
|
128
|
+
body: {
|
|
129
|
+
type: InteractionResponseType.ChannelMessageWithSource,
|
|
130
|
+
data: serialized
|
|
131
|
+
}
|
|
132
|
+
}, {
|
|
133
|
+
with_response: true
|
|
134
|
+
}));
|
|
135
|
+
if (!done.resource?.message)
|
|
136
|
+
throw new Error(`No resource returned for message from interaction callback: ${done.resource}`);
|
|
137
|
+
return new Message(this.client, done.resource.message);
|
|
91
138
|
}
|
|
92
139
|
/**
|
|
93
140
|
* Defer the interaction response. This is used automatically by commands that are set to defer.
|
|
@@ -116,6 +163,11 @@ export class BaseInteraction extends Base {
|
|
|
116
163
|
async showModal(modal) {
|
|
117
164
|
if (this._deferred)
|
|
118
165
|
throw new Error("You cannot defer an interaction that shows a modal");
|
|
166
|
+
const key = modal.customIdParser(modal.customId).key;
|
|
167
|
+
const existingModal = this.client.modalHandler.modals.find((m) => m.customIdParser(m.customId).key === key);
|
|
168
|
+
if (!existingModal) {
|
|
169
|
+
this.client.modalHandler.registerModal(modal);
|
|
170
|
+
}
|
|
119
171
|
await this.client.rest.post(Routes.interactionCallback(this.rawData.id, this.rawData.token), {
|
|
120
172
|
body: {
|
|
121
173
|
type: InteractionResponseType.Modal,
|
|
@@ -128,11 +180,44 @@ export class BaseInteraction extends Base {
|
|
|
128
180
|
*/
|
|
129
181
|
async followUp(reply) {
|
|
130
182
|
const serialized = serializePayload(reply);
|
|
183
|
+
// Auto-register any components in the message
|
|
184
|
+
this._internalAutoRegisterComponentsOnSend(reply);
|
|
131
185
|
await this.client.rest.post(Routes.webhook(this.client.options.clientId, this.rawData.token), {
|
|
132
186
|
body: {
|
|
133
187
|
...serialized
|
|
134
188
|
}
|
|
135
189
|
});
|
|
136
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* This function will reply to the interaction and wait for a component to be pressed.
|
|
193
|
+
* Any components passed in the message will not have run() functions called and
|
|
194
|
+
* will only trigger the interaction.acknowledge() function.
|
|
195
|
+
* This function will also return a promise that resolves
|
|
196
|
+
* to the custom ID of the component that was pressed.
|
|
197
|
+
*
|
|
198
|
+
* @param data The message data to send
|
|
199
|
+
* @param timeout After this many milliseconds, the promise will resolve to null
|
|
200
|
+
*/
|
|
201
|
+
async replyAndWaitForComponent(data, timeout = 300000) {
|
|
202
|
+
const message = await this.reply(data, true);
|
|
203
|
+
const id = `${message.id}-${message.channelId}`;
|
|
204
|
+
return new Promise((resolve) => {
|
|
205
|
+
const timer = setTimeout(() => {
|
|
206
|
+
this.client.componentHandler.oneOffComponents.delete(id);
|
|
207
|
+
resolve({ success: false, reason: "timed out" });
|
|
208
|
+
}, timeout);
|
|
209
|
+
this.client.componentHandler.oneOffComponents.set(id, {
|
|
210
|
+
resolve: (data) => {
|
|
211
|
+
clearTimeout(timer);
|
|
212
|
+
this.client.componentHandler.oneOffComponents.delete(id);
|
|
213
|
+
resolve({
|
|
214
|
+
success: true,
|
|
215
|
+
customId: data.custom_id,
|
|
216
|
+
values: "values" in data ? data.values : undefined
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
}
|
|
137
222
|
}
|
|
138
223
|
//# sourceMappingURL=BaseInteraction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseInteraction.js","sourceRoot":"","sources":["../../../src/abstracts/BaseInteraction.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"BaseInteraction.js","sourceRoot":"","sources":["../../../src/abstracts/BaseInteraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,uBAAuB,EAEvB,YAAY,EAKZ,MAAM,EACN,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACN,+BAA+B,EAE/B,SAAS,EACT,KAAK,EACL,KAAK,EACL,OAAO,EAEP,GAAG,EACH,OAAO,EACP,IAAI,EACJ,cAAc,EACd,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAMhC;;GAEG;AACH,MAAM,OAAgB,eAA0C,SAAQ,IAAI;IAC3E;;OAEG;IACH,IAAI,CAAiB;IACrB;;OAEG;IACH,OAAO,CAAG;IACV;;OAEG;IACH,MAAM,CAAoB;IAE1B;;;OAGG;IACH,SAAS,GAAG,KAAK,CAAA;IAET,gBAAgB,GAAG,KAAK,CAAA;IAEhC,YAAY,MAAc,EAAE,IAAO,EAAE,QAA6B;QACjE,KAAK,CAAC,MAAM,CAAC,CAAA;QACb,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;QACrB,IAAI,CAAC,MAAM;YACV,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,SAAS,CAAA;QACnE,IAAI,QAAQ,CAAC,SAAS;YAAE,IAAI,CAAC,gBAAgB,GAAG,QAAQ,CAAC,SAAS,CAAA;IACnE,CAAC;IAED,IAAI,MAAM;QACT,IAAI,CAAC,IAAI,CA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AAO,GAAG,MAAM;QA2BhB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAE5C,MAAM,EAAE,GAA0B,GAAG,OAAO,CAAC,EAAE,IAAI,OAAO,CAAC,SAAS,EAAE,CAAA;QAEtE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC9B,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;gBAC7B,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;gBACxD,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAA;YACjD,CAAC,EAAE,OAAO,CAAC,CAAA;YACX,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,EAAE;gBACrD,OAAO,EAAE,CAAC,IAAwC,EAAE,EAAE;oBACrD,YAAY,CAAC,KAAK,CAAC,CAAA;oBACnB,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;oBACxD,OAAO,CAAC;wBACP,OAAO,EAAE,IAAI;wBACb,QAAQ,EAAE,IAAI,CAAC,SAAS;wBACxB,MAAM,EAAE,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;qBAClD,CAAC,CAAA;gBACH,CAAC;aACD,CAAC,CAAA;QACH,CAAC,CAAC,CAAA;IACH,CAAC;CACD"}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import type { APIComponentInMessageActionRow, ComponentType } from "discord-api-types/v10";
|
|
2
|
+
import type { ComponentData, ComponentParserResult } from "../types/index.js";
|
|
2
3
|
import { BaseComponent } from "./BaseComponent.js";
|
|
3
|
-
|
|
4
|
-
[key: string]: string | number | boolean;
|
|
5
|
-
};
|
|
4
|
+
import type { BaseComponentInteraction } from "./BaseComponentInteraction.js";
|
|
6
5
|
export declare abstract class BaseMessageInteractiveComponent extends BaseComponent {
|
|
7
6
|
abstract type: ComponentType.Button | ComponentType.StringSelect | ComponentType.TextInput | ComponentType.UserSelect | ComponentType.RoleSelect | ComponentType.MentionableSelect | ComponentType.ChannelSelect;
|
|
8
7
|
readonly isV2 = false;
|
|
9
|
-
constructor(data?: {
|
|
10
|
-
additionalData?: ComponentAdditionalData;
|
|
11
|
-
});
|
|
12
8
|
/**
|
|
13
9
|
* Whether the component response should be automatically deferred
|
|
14
10
|
*/
|
|
@@ -18,16 +14,26 @@ export declare abstract class BaseMessageInteractiveComponent extends BaseCompon
|
|
|
18
14
|
*/
|
|
19
15
|
ephemeral: boolean;
|
|
20
16
|
/**
|
|
21
|
-
* The custom ID of the component
|
|
17
|
+
* The custom ID of the component.
|
|
18
|
+
* If you want to provide a custom ID with additional data, you should either follow the default parser's format or implement your own custom parser.
|
|
19
|
+
*
|
|
20
|
+
* @see {@link customIdParser}
|
|
22
21
|
*/
|
|
23
22
|
abstract customId: string;
|
|
24
|
-
additionalData: ComponentAdditionalData | null;
|
|
25
23
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
24
|
+
* This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
|
|
25
|
+
* By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
|
|
26
|
+
* It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
|
|
27
|
+
*
|
|
28
|
+
* You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
|
|
29
|
+
* - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
|
|
30
|
+
* - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
|
|
31
|
+
*
|
|
32
|
+
* @param id - The custom ID of the component as received from an interaction event
|
|
33
|
+
* @returns The base key and the data object
|
|
29
34
|
*/
|
|
30
|
-
|
|
35
|
+
customIdParser: (id: string) => ComponentParserResult;
|
|
31
36
|
abstract serialize: () => APIComponentInMessageActionRow;
|
|
37
|
+
run(interaction: BaseComponentInteraction, data: ComponentData): unknown | Promise<unknown>;
|
|
32
38
|
}
|
|
33
39
|
//# sourceMappingURL=BaseMessageInteractiveComponent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseMessageInteractiveComponent.d.ts","sourceRoot":"","sources":["../../../src/abstracts/BaseMessageInteractiveComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,8BAA8B,EAC9B,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"BaseMessageInteractiveComponent.d.ts","sourceRoot":"","sources":["../../../src/abstracts/BaseMessageInteractiveComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,8BAA8B,EAC9B,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAE7E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAA;AAE7E,8BAAsB,+BAAgC,SAAQ,aAAa;IAC1E,QAAQ,CAAC,IAAI,EACV,aAAa,CAAC,MAAM,GACpB,aAAa,CAAC,YAAY,GAC1B,aAAa,CAAC,SAAS,GACvB,aAAa,CAAC,UAAU,GACxB,aAAa,CAAC,UAAU,GACxB,aAAa,CAAC,iBAAiB,GAC/B,aAAa,CAAC,aAAa,CAAA;IAE9B,QAAQ,CAAC,IAAI,SAAQ;IAErB;;OAEG;IACH,KAAK,UAAQ;IACb;;OAEG;IACH,SAAS,UAAQ;IAEjB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB;;;;;;;;;;;OAWG;IACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,qBAAqB,CAAgB;IAErE,QAAQ,CAAC,SAAS,EAAE,MAAM,8BAA8B,CAAA;IAExD,GAAG,CACF,WAAW,EAAE,wBAAwB,EACrC,IAAI,EAAE,aAAa,GACjB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;CAM7B"}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
+
import { parseCustomId } from "../utils/customIdParser.js";
|
|
1
2
|
import { BaseComponent } from "./BaseComponent.js";
|
|
2
3
|
export class BaseMessageInteractiveComponent extends BaseComponent {
|
|
3
4
|
isV2 = false;
|
|
4
|
-
constructor(data) {
|
|
5
|
-
super();
|
|
6
|
-
if (data?.additionalData)
|
|
7
|
-
this.additionalData = data.additionalData;
|
|
8
|
-
}
|
|
9
5
|
/**
|
|
10
6
|
* Whether the component response should be automatically deferred
|
|
11
7
|
*/
|
|
@@ -14,20 +10,24 @@ export class BaseMessageInteractiveComponent extends BaseComponent {
|
|
|
14
10
|
* Whether the component response should be ephemeral
|
|
15
11
|
*/
|
|
16
12
|
ephemeral = false;
|
|
17
|
-
additionalData = null;
|
|
18
13
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
14
|
+
* This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
|
|
15
|
+
* By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
|
|
16
|
+
* It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
|
|
17
|
+
*
|
|
18
|
+
* You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
|
|
19
|
+
* - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
|
|
20
|
+
* - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
|
|
21
|
+
*
|
|
22
|
+
* @param id - The custom ID of the component as received from an interaction event
|
|
23
|
+
* @returns The base key and the data object
|
|
22
24
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return id;
|
|
31
|
-
};
|
|
25
|
+
customIdParser = parseCustomId;
|
|
26
|
+
run(interaction, data) {
|
|
27
|
+
// Random things to show the vars as used
|
|
28
|
+
typeof interaction === "string";
|
|
29
|
+
typeof data === "string";
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
32
|
}
|
|
33
33
|
//# sourceMappingURL=BaseMessageInteractiveComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseMessageInteractiveComponent.js","sourceRoot":"","sources":["../../../src/abstracts/BaseMessageInteractiveComponent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BaseMessageInteractiveComponent.js","sourceRoot":"","sources":["../../../src/abstracts/BaseMessageInteractiveComponent.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGlD,MAAM,OAAgB,+BAAgC,SAAQ,aAAa;IAUjE,IAAI,GAAG,KAAK,CAAA;IAErB;;OAEG;IACH,KAAK,GAAG,KAAK,CAAA;IACb;;OAEG;IACH,SAAS,GAAG,KAAK,CAAA;IAUjB;;;;;;;;;;;OAWG;IACH,cAAc,GAA0C,aAAa,CAAA;IAIrE,GAAG,CACF,WAAqC,EACrC,IAAmB;QAEnB,yCAAyC;QACzC,OAAO,WAAW,KAAK,QAAQ,CAAA;QAC/B,OAAO,IAAI,KAAK,QAAQ,CAAA;QACxB,OAAM;IACP,CAAC;CACD"}
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
import type { APIComponentInModalActionRow, ComponentType } from "discord-api-types/v10";
|
|
2
|
+
import type { ComponentParserResult } from "../types/index.js";
|
|
2
3
|
import { BaseComponent } from "./BaseComponent.js";
|
|
3
|
-
import type { ComponentAdditionalData } from "./BaseMessageInteractiveComponent.js";
|
|
4
4
|
export declare abstract class BaseModalComponent extends BaseComponent {
|
|
5
5
|
abstract type: ComponentType.TextInput;
|
|
6
6
|
readonly isV2 = false;
|
|
7
|
-
constructor(data?: {
|
|
8
|
-
additionalData?: ComponentAdditionalData;
|
|
9
|
-
});
|
|
10
7
|
/**
|
|
11
|
-
* The custom ID of the component
|
|
8
|
+
* The custom ID of the component.
|
|
9
|
+
* If you want to provide a custom ID with additional data, you should either follow the default parser's format or implement your own custom parser.
|
|
10
|
+
*
|
|
11
|
+
* @see {@link customIdParser}
|
|
12
12
|
*/
|
|
13
13
|
abstract customId: string;
|
|
14
|
-
additionalData: ComponentAdditionalData | null;
|
|
15
14
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
|
|
16
|
+
* By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
|
|
17
|
+
* It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
|
|
18
|
+
*
|
|
19
|
+
* You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
|
|
20
|
+
* - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
|
|
21
|
+
* - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
|
|
22
|
+
*
|
|
23
|
+
* @param id - The custom ID of the component as received from an interaction event
|
|
24
|
+
* @returns The base key and the data object
|
|
19
25
|
*/
|
|
20
|
-
|
|
26
|
+
customIdParser: (id: string) => ComponentParserResult;
|
|
21
27
|
abstract serialize: () => APIComponentInModalActionRow;
|
|
22
28
|
}
|
|
23
29
|
//# sourceMappingURL=BaseModalComponent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseModalComponent.d.ts","sourceRoot":"","sources":["../../../src/abstracts/BaseModalComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,4BAA4B,EAC5B,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"BaseModalComponent.d.ts","sourceRoot":"","sources":["../../../src/abstracts/BaseModalComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,4BAA4B,EAC5B,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,8BAAsB,kBAAmB,SAAQ,aAAa;IAC7D,SAAkB,IAAI,EAAE,aAAa,CAAC,SAAS,CAAA;IAE/C,QAAQ,CAAC,IAAI,SAAQ;IAErB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB;;;;;;;;;;;OAWG;IACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,qBAAqB,CAcpD;IAED,QAAQ,CAAC,SAAS,EAAE,MAAM,4BAA4B,CAAA;CACtD"}
|
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
import { BaseComponent } from "./BaseComponent.js";
|
|
2
2
|
export class BaseModalComponent extends BaseComponent {
|
|
3
3
|
isV2 = false;
|
|
4
|
-
constructor(data) {
|
|
5
|
-
super();
|
|
6
|
-
if (data?.additionalData)
|
|
7
|
-
this.additionalData = data.additionalData;
|
|
8
|
-
}
|
|
9
|
-
additionalData = null;
|
|
10
4
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
5
|
+
* This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
|
|
6
|
+
* By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
|
|
7
|
+
* It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
|
|
8
|
+
*
|
|
9
|
+
* You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
|
|
10
|
+
* - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
|
|
11
|
+
* - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
|
|
12
|
+
*
|
|
13
|
+
* @param id - The custom ID of the component as received from an interaction event
|
|
14
|
+
* @returns The base key and the data object
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
.
|
|
22
|
-
|
|
16
|
+
customIdParser = (id) => {
|
|
17
|
+
const [key, ...data] = id.split(":");
|
|
18
|
+
if (!key)
|
|
19
|
+
throw new Error(`Invalid component ID: ${id}`);
|
|
20
|
+
return {
|
|
21
|
+
key,
|
|
22
|
+
data: Object.fromEntries(data.map((d) => {
|
|
23
|
+
const [k, v] = d.split("=");
|
|
24
|
+
if (v === "true")
|
|
25
|
+
return [k, true];
|
|
26
|
+
if (v === "false")
|
|
27
|
+
return [k, false];
|
|
28
|
+
return [k, Number.isNaN(Number(v)) ? v : Number(v)];
|
|
29
|
+
}))
|
|
30
|
+
};
|
|
23
31
|
};
|
|
24
32
|
}
|
|
25
33
|
//# sourceMappingURL=BaseModalComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseModalComponent.js","sourceRoot":"","sources":["../../../src/abstracts/BaseModalComponent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BaseModalComponent.js","sourceRoot":"","sources":["../../../src/abstracts/BaseModalComponent.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,MAAM,OAAgB,kBAAmB,SAAQ,aAAa;IAGpD,IAAI,GAAG,KAAK,CAAA;IAUrB;;;;;;;;;;;OAWG;IACH,cAAc,GAA0C,CAAC,EAAE,EAAE,EAAE;QAC9D,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACpC,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,EAAE,EAAE,CAAC,CAAA;QACxD,OAAO;YACN,GAAG;YACH,IAAI,EAAE,MAAM,CAAC,WAAW,CACvB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;gBACd,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;gBAC3B,IAAI,CAAC,KAAK,MAAM;oBAAE,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAAA;gBAClC,IAAI,CAAC,KAAK,OAAO;oBAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;gBACpC,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;YACpD,CAAC,CAAC,CACF;SACD,CAAA;IACF,CAAC,CAAA;CAGD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { APIGuildForumDefaultReactionEmoji, APIGuildForumTag, APIThreadOnlyChannel, ChannelType, SortOrderType } from "discord-api-types/v10";
|
|
2
|
+
import type { Message } from "../structures/Message.js";
|
|
2
3
|
import type { MessagePayload } from "../types/index.js";
|
|
3
|
-
import type { IfPartial } from "../
|
|
4
|
+
import type { IfPartial } from "../types/index.js";
|
|
4
5
|
import { BaseGuildChannel } from "./BaseGuildChannel.js";
|
|
5
6
|
export declare abstract class GuildThreadOnlyChannel<Type extends ChannelType.GuildForum | ChannelType.GuildMedia, IsPartial extends boolean = false> extends BaseGuildChannel<Type, IsPartial> {
|
|
6
7
|
rawData: APIThreadOnlyChannel<Type> | null;
|
|
@@ -32,12 +33,12 @@ export declare abstract class GuildThreadOnlyChannel<Type extends ChannelType.Gu
|
|
|
32
33
|
* You cannot send a message directly to a forum or media channel, so this method throws an error.
|
|
33
34
|
* Use {@link GuildThreadChannel.send} instead, or the alias {@link GuildThreadOnlyChannel.sendToPost} instead, to send a message to the channel's posts.
|
|
34
35
|
*/
|
|
35
|
-
send(): Promise<
|
|
36
|
+
send(): Promise<never>;
|
|
36
37
|
/**
|
|
37
38
|
* Send a message to a post in the channel
|
|
38
39
|
* @remarks
|
|
39
40
|
* This is an alias for {@link GuildThreadChannel.send} that will fetch the channel, but if you already have the channel, you can use {@link GuildThreadChannel.send} instead.
|
|
40
41
|
*/
|
|
41
|
-
sendToPost(message: MessagePayload, postId: string): Promise<
|
|
42
|
+
sendToPost(message: MessagePayload, postId: string): Promise<Message>;
|
|
42
43
|
}
|
|
43
44
|
//# sourceMappingURL=GuildThreadOnlyChannel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GuildThreadOnlyChannel.d.ts","sourceRoot":"","sources":["../../../src/abstracts/GuildThreadOnlyChannel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,iCAAiC,EACjC,gBAAgB,EAChB,oBAAoB,EACpB,WAAW,EACX,aAAa,EAEb,MAAM,uBAAuB,CAAA;AAE9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"G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OAAO,CAAC,KAAK,CAAC;IAMrC;;;;OAIG;IACG,UAAU,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAO3E"}
|
|
@@ -63,7 +63,7 @@ export class GuildThreadOnlyChannel extends BaseGuildChannel {
|
|
|
63
63
|
*/
|
|
64
64
|
async sendToPost(message, postId) {
|
|
65
65
|
const channel = new GuildThreadChannel(this.client, postId);
|
|
66
|
-
await channel.send(message);
|
|
66
|
+
return await channel.send(message);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
//# sourceMappingURL=GuildThreadOnlyChannel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GuildThreadOnlyChannel.js","sourceRoot":"","sources":["../../../src/abstracts/GuildThreadOnlyChannel.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;
|
|
1
|
+
{"version":3,"file":"GuildThreadOnlyChannel.js","sourceRoot":"","sources":["../../../src/abstracts/GuildThreadOnlyChannel.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AAIxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,MAAM,OAAgB,sBAGpB,SAAQ,gBAAiC;IAG1C;;OAEG;IACH,IAAI,KAAK;QACR,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO,SAAkB,CAAA;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,IAAI,CAAA;IAClC,CAAC;IAED;;OAEG;IACH,IAAI,0BAA0B;QAC7B,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO,SAAkB,CAAA;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,6BAA6B,IAAI,IAAI,CAAA;IAC1D,CAAC;IAED;;OAEG;IACH,IAAI,6BAA6B;QAChC,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO,SAAkB,CAAA;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,kCAAkC,IAAI,IAAI,CAAA;IAC/D,CAAC;IAED;;OAEG;IACH,IAAI,aAAa;QAChB,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO,SAAkB,CAAA;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,IAAI,EAAE,CAAA;IACzC,CAAC;IAED;;OAEG;IACH,IAAI,oBAAoB;QAIvB,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO,SAAkB,CAAA;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAA;IAC3C,CAAC;IAED;;OAEG;IACH,IAAI,gBAAgB;QACnB,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO,SAAkB,CAAA;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAA;IACvC,CAAC;IAED;;;OAGG;IACM,KAAK,CAAC,IAAI;QAClB,MAAM,IAAI,KAAK,CACd,wMAAwM,CACxM,CAAA;IACF,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,UAAU,CAAC,OAAuB,EAAE,MAAc;QACvD,MAAM,OAAO,GAAG,IAAI,kBAAkB,CACrC,IAAI,CAAC,MAAM,EACX,MAAM,CACN,CAAA;QACD,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACnC,CAAC;CACD"}
|
|
@@ -6,7 +6,7 @@ export declare abstract class Plugin {
|
|
|
6
6
|
/**
|
|
7
7
|
* An ID that identifies the plugin uniquely between all other used plugins in the Client
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
abstract readonly id: string;
|
|
10
10
|
/**
|
|
11
11
|
* Registers the client with this plugin
|
|
12
12
|
* @param client The client to register
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../../src/abstracts/Plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAElD;;GAEG;AACH,8BAAsB,MAAM;IAC3B;;OAEG;IACH,
|
|
1
|
+
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../../src/abstracts/Plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAElD;;GAEG;AACH,8BAAsB,MAAM;IAC3B;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IAC5B;;;OAGG;IACH,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAErD;;;OAGG;IACH,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;CACrD;AAED,MAAM,WAAW,KAAK;IACrB;;OAEG;IACH,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAA;IAEnD;;OAEG;IACH,IAAI,EAAE,IAAI,MAAM,EAAE,CAAA;IAElB;;;;;OAKG;IACH,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;IAElE;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IAEnB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,OAAO;IAEvB,SAAS,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;CACvC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BaseCommand } from "../abstracts/BaseCommand.js";
|
|
2
2
|
import type { BaseListener } from "../abstracts/BaseListener.js";
|
|
3
|
+
import type { BaseMessageInteractiveComponent } from "../abstracts/BaseMessageInteractiveComponent.js";
|
|
3
4
|
import type { Context, Plugin, Route } from "../abstracts/Plugin.js";
|
|
4
5
|
import { CommandHandler } from "../internals/CommandHandler.js";
|
|
5
6
|
import { ComponentHandler } from "../internals/ComponentHandler.js";
|
|
@@ -10,6 +11,7 @@ import { GuildMember } from "../structures/GuildMember.js";
|
|
|
10
11
|
import { Message } from "../structures/Message.js";
|
|
11
12
|
import { Role } from "../structures/Role.js";
|
|
12
13
|
import { User } from "../structures/User.js";
|
|
14
|
+
import { Webhook, type WebhookInput } from "../structures/Webhook.js";
|
|
13
15
|
import { RequestClient, type RequestClientOptions } from "./RequestClient.js";
|
|
14
16
|
/**
|
|
15
17
|
* The options used for initializing the client
|
|
@@ -45,12 +47,6 @@ export interface ClientOptions {
|
|
|
45
47
|
* @default false
|
|
46
48
|
*/
|
|
47
49
|
autoDeploy?: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Whether components and modals should not be registered automatically.
|
|
50
|
-
* If you want you register components yourself (e.g. you are changing them at runtime), you can manually call {@link ComponentHandler#registerComponent} and {@link ModalHandler#registerModal} on the client.
|
|
51
|
-
* @default false
|
|
52
|
-
*/
|
|
53
|
-
disableAutoRegister?: boolean;
|
|
54
50
|
/**
|
|
55
51
|
* Whether the deploy route should be disabled.
|
|
56
52
|
* @default false
|
|
@@ -66,6 +62,11 @@ export interface ClientOptions {
|
|
|
66
62
|
* @default false
|
|
67
63
|
*/
|
|
68
64
|
disableEventsRoute?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* A list of guild IDs to deploy all commands to during development (guild command deployment is instant and rate-limited higher).
|
|
67
|
+
* If set, all commands will be deployed to these guilds instead of globally.
|
|
68
|
+
*/
|
|
69
|
+
devGuilds?: string[];
|
|
69
70
|
}
|
|
70
71
|
/**
|
|
71
72
|
* The main client used to interact with Discord
|
|
@@ -91,6 +92,10 @@ export declare class Client {
|
|
|
91
92
|
* The event listeners that the client has registered
|
|
92
93
|
*/
|
|
93
94
|
listeners: BaseListener[];
|
|
95
|
+
/**
|
|
96
|
+
* The components that the client has globally registered
|
|
97
|
+
*/
|
|
98
|
+
components: BaseMessageInteractiveComponent[];
|
|
94
99
|
/**
|
|
95
100
|
* The rest client used to interact with the Discord API
|
|
96
101
|
*/
|
|
@@ -115,6 +120,14 @@ export declare class Client {
|
|
|
115
120
|
* @internal
|
|
116
121
|
*/
|
|
117
122
|
eventHandler: EventHandler;
|
|
123
|
+
/**
|
|
124
|
+
* The ID of the shard this client is running on, if sharding is enabled
|
|
125
|
+
*/
|
|
126
|
+
shardId?: number;
|
|
127
|
+
/**
|
|
128
|
+
* The total number of shards, if sharding is enabled
|
|
129
|
+
*/
|
|
130
|
+
totalShards?: number;
|
|
118
131
|
/**
|
|
119
132
|
* Creates a new client
|
|
120
133
|
* @param options The options used to initialize the client
|
|
@@ -124,6 +137,7 @@ export declare class Client {
|
|
|
124
137
|
constructor(options: ClientOptions, handlers: {
|
|
125
138
|
commands?: BaseCommand[];
|
|
126
139
|
listeners?: BaseListener[];
|
|
140
|
+
components?: BaseMessageInteractiveComponent[];
|
|
127
141
|
}, plugins?: Plugin[]);
|
|
128
142
|
private appendRoutes;
|
|
129
143
|
/**
|
|
@@ -134,6 +148,7 @@ export declare class Client {
|
|
|
134
148
|
/**
|
|
135
149
|
* Handle an interaction request from Discord
|
|
136
150
|
* @param req The request to handle
|
|
151
|
+
* @param ctx The context for the request
|
|
137
152
|
* @returns A response
|
|
138
153
|
*/
|
|
139
154
|
handleEventsRequest(req: Request): Promise<Response>;
|
|
@@ -187,6 +202,12 @@ export declare class Client {
|
|
|
187
202
|
* @returns The message data
|
|
188
203
|
*/
|
|
189
204
|
fetchMessage(channelId: string, messageId: string): Promise<Message<false>>;
|
|
205
|
+
/**
|
|
206
|
+
* Fetch a webhook from the Discord API
|
|
207
|
+
* @param input The webhook data, ID and token, or webhook URL
|
|
208
|
+
* @returns The webhook data
|
|
209
|
+
*/
|
|
210
|
+
fetchWebhook(input: WebhookInput): Promise<Webhook<false>>;
|
|
190
211
|
}
|
|
191
212
|
/**
|
|
192
213
|
* @hidden
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../../src/classes/Client.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAEpE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../../src/classes/Client.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,iDAAiD,CAAA;AACtG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAEpE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D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