@buape/carbon 0.6.1 → 0.8.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 +8 -7
- package/dist/src/abstracts/AnySelectMenu.d.ts +2 -2
- package/dist/src/abstracts/AnySelectMenu.d.ts.map +1 -1
- package/dist/src/abstracts/AnySelectMenu.js +2 -2
- package/dist/src/abstracts/AnySelectMenu.js.map +1 -1
- package/dist/src/abstracts/BaseChannel.d.ts +2 -2
- package/dist/src/abstracts/BaseChannel.d.ts.map +1 -1
- package/dist/src/abstracts/BaseChannel.js +2 -1
- package/dist/src/abstracts/BaseChannel.js.map +1 -1
- package/dist/src/abstracts/BaseCommand.d.ts +7 -4
- package/dist/src/abstracts/BaseCommand.d.ts.map +1 -1
- package/dist/src/abstracts/BaseCommand.js +17 -4
- package/dist/src/abstracts/BaseCommand.js.map +1 -1
- package/dist/src/abstracts/BaseComponent.d.ts +10 -24
- package/dist/src/abstracts/BaseComponent.d.ts.map +1 -1
- package/dist/src/abstracts/BaseComponent.js +5 -25
- package/dist/src/abstracts/BaseComponent.js.map +1 -1
- package/dist/src/abstracts/BaseComponentInteraction.d.ts +3 -3
- package/dist/src/abstracts/BaseComponentInteraction.d.ts.map +1 -1
- package/dist/src/abstracts/BaseComponentInteraction.js +2 -3
- package/dist/src/abstracts/BaseComponentInteraction.js.map +1 -1
- package/dist/src/abstracts/BaseGuildChannel.d.ts +1 -1
- package/dist/src/abstracts/BaseGuildChannel.d.ts.map +1 -1
- package/dist/src/abstracts/BaseInteraction.d.ts +5 -35
- package/dist/src/abstracts/BaseInteraction.d.ts.map +1 -1
- package/dist/src/abstracts/BaseInteraction.js +10 -24
- package/dist/src/abstracts/BaseInteraction.js.map +1 -1
- package/dist/src/abstracts/BaseListener.d.ts +13 -0
- package/dist/src/abstracts/BaseListener.d.ts.map +1 -0
- package/dist/src/abstracts/BaseListener.js +8 -0
- package/dist/src/abstracts/BaseListener.js.map +1 -0
- package/dist/src/abstracts/BaseMessageInteractiveComponent.d.ts +33 -0
- package/dist/src/abstracts/BaseMessageInteractiveComponent.d.ts.map +1 -0
- package/dist/src/abstracts/BaseMessageInteractiveComponent.js +33 -0
- package/dist/src/abstracts/BaseMessageInteractiveComponent.js.map +1 -0
- package/dist/src/abstracts/BaseModalComponent.d.ts +23 -0
- package/dist/src/abstracts/BaseModalComponent.d.ts.map +1 -0
- package/dist/src/abstracts/BaseModalComponent.js +25 -0
- package/dist/src/abstracts/BaseModalComponent.js.map +1 -0
- package/dist/src/abstracts/GuildThreadOnlyChannel.d.ts +1 -1
- package/dist/src/abstracts/GuildThreadOnlyChannel.d.ts.map +1 -1
- package/dist/src/abstracts/Plugin.d.ts +36 -1
- package/dist/src/abstracts/Plugin.d.ts.map +1 -1
- package/dist/src/abstracts/Plugin.js +3 -1
- package/dist/src/abstracts/Plugin.js.map +1 -1
- package/dist/src/adapters/bun/index.d.ts +8 -12
- package/dist/src/adapters/bun/index.d.ts.map +1 -1
- package/dist/src/adapters/bun/index.js +9 -13
- package/dist/src/adapters/bun/index.js.map +1 -1
- package/dist/src/adapters/fetch/index.d.ts +10 -0
- package/dist/src/adapters/fetch/index.d.ts.map +1 -0
- package/dist/src/adapters/fetch/index.js +45 -0
- package/dist/src/adapters/fetch/index.js.map +1 -0
- package/dist/src/adapters/node/index.d.ts +8 -12
- package/dist/src/adapters/node/index.d.ts.map +1 -1
- package/dist/src/adapters/node/index.js +10 -13
- package/dist/src/adapters/node/index.js.map +1 -1
- package/dist/src/classes/Client.d.ts +56 -9
- package/dist/src/classes/Client.d.ts.map +1 -1
- package/dist/src/classes/Client.js +94 -21
- package/dist/src/classes/Client.js.map +1 -1
- package/dist/src/classes/Listener.d.ts +359 -0
- package/dist/src/classes/Listener.d.ts.map +1 -0
- package/dist/src/classes/Listener.js +911 -0
- package/dist/src/classes/Listener.js.map +1 -0
- package/dist/src/classes/Modal.d.ts +3 -3
- package/dist/src/classes/Modal.d.ts.map +1 -1
- package/dist/src/classes/Modal.js.map +1 -1
- package/dist/src/classes/RequestClient.d.ts +77 -0
- package/dist/src/classes/RequestClient.d.ts.map +1 -0
- package/dist/src/classes/RequestClient.js +213 -0
- package/dist/src/classes/RequestClient.js.map +1 -0
- package/dist/src/classes/{Button.d.ts → components/Button.d.ts} +5 -4
- package/dist/src/classes/components/Button.d.ts.map +1 -0
- package/dist/src/classes/{Button.js → components/Button.js} +3 -2
- package/dist/src/classes/components/Button.js.map +1 -0
- package/dist/src/classes/{ChannelSelectMenu.d.ts → components/ChannelSelectMenu.d.ts} +4 -3
- package/dist/src/classes/components/ChannelSelectMenu.d.ts.map +1 -0
- package/dist/src/classes/{ChannelSelectMenu.js → components/ChannelSelectMenu.js} +2 -1
- package/dist/src/classes/components/ChannelSelectMenu.js.map +1 -0
- package/dist/src/classes/components/Container.d.ts +26 -0
- package/dist/src/classes/components/Container.d.ts.map +1 -0
- package/dist/src/classes/components/Container.js +30 -0
- package/dist/src/classes/components/Container.js.map +1 -0
- package/dist/src/classes/components/File.d.ts +21 -0
- package/dist/src/classes/components/File.d.ts.map +1 -0
- package/dist/src/classes/components/File.js +33 -0
- package/dist/src/classes/components/File.js.map +1 -0
- package/dist/src/classes/components/MediaGallery.d.ts +27 -0
- package/dist/src/classes/components/MediaGallery.d.ts.map +1 -0
- package/dist/src/classes/components/MediaGallery.js +27 -0
- package/dist/src/classes/components/MediaGallery.js.map +1 -0
- package/dist/src/classes/{MentionableSelectMenu.d.ts → components/MentionableSelectMenu.d.ts} +4 -3
- package/dist/src/classes/components/MentionableSelectMenu.d.ts.map +1 -0
- package/dist/src/classes/{MentionableSelectMenu.js → components/MentionableSelectMenu.js} +2 -1
- package/dist/src/classes/components/MentionableSelectMenu.js.map +1 -0
- package/dist/src/classes/{RoleSelectMenu.d.ts → components/RoleSelectMenu.d.ts} +4 -3
- package/dist/src/classes/components/RoleSelectMenu.d.ts.map +1 -0
- package/dist/src/classes/{RoleSelectMenu.js → components/RoleSelectMenu.js} +2 -1
- package/dist/src/classes/components/RoleSelectMenu.js.map +1 -0
- package/dist/src/classes/components/Row.d.ts +29 -0
- package/dist/src/classes/components/Row.d.ts.map +1 -0
- package/dist/src/classes/{Row.js → components/Row.js} +8 -2
- package/dist/src/classes/components/Row.js.map +1 -0
- package/dist/src/classes/components/Section.d.ts +22 -0
- package/dist/src/classes/components/Section.d.ts.map +1 -0
- package/dist/src/classes/components/Section.js +15 -0
- package/dist/src/classes/components/Section.js.map +1 -0
- package/dist/src/classes/components/Separator.d.ts +22 -0
- package/dist/src/classes/components/Separator.d.ts.map +1 -0
- package/dist/src/classes/components/Separator.js +33 -0
- package/dist/src/classes/components/Separator.js.map +1 -0
- package/dist/src/classes/{StringSelectMenu.d.ts → components/StringSelectMenu.d.ts} +4 -3
- package/dist/src/classes/components/StringSelectMenu.d.ts.map +1 -0
- package/dist/src/classes/{StringSelectMenu.js → components/StringSelectMenu.js} +2 -1
- package/dist/src/classes/components/StringSelectMenu.js.map +1 -0
- package/dist/src/classes/components/TextDisplay.d.ts +10 -0
- package/dist/src/classes/components/TextDisplay.d.ts.map +1 -0
- package/dist/src/classes/components/TextDisplay.js +19 -0
- package/dist/src/classes/components/TextDisplay.js.map +1 -0
- package/dist/src/classes/{TextInput.d.ts → components/TextInput.d.ts} +4 -3
- package/dist/src/classes/components/TextInput.d.ts.map +1 -0
- package/dist/src/classes/{TextInput.js → components/TextInput.js} +3 -2
- package/dist/src/classes/components/TextInput.js.map +1 -0
- package/dist/src/classes/components/Thumbnail.d.ts +13 -0
- package/dist/src/classes/components/Thumbnail.d.ts.map +1 -0
- package/dist/src/classes/components/Thumbnail.js +16 -0
- package/dist/src/classes/components/Thumbnail.js.map +1 -0
- package/dist/src/classes/{UserSelectMenu.d.ts → components/UserSelectMenu.d.ts} +4 -3
- package/dist/src/classes/components/UserSelectMenu.d.ts.map +1 -0
- package/dist/src/classes/{UserSelectMenu.js → components/UserSelectMenu.js} +2 -1
- package/dist/src/classes/components/UserSelectMenu.js.map +1 -0
- package/dist/src/errors/BaseError.d.ts +3 -0
- package/dist/src/errors/BaseError.d.ts.map +1 -0
- package/dist/src/errors/BaseError.js +3 -0
- package/dist/src/errors/BaseError.js.map +1 -0
- package/dist/src/errors/DiscordError.d.ts +25 -0
- package/dist/src/errors/DiscordError.d.ts.map +1 -0
- package/dist/src/errors/DiscordError.js +31 -0
- package/dist/src/errors/DiscordError.js.map +1 -0
- package/dist/src/errors/RatelimitError.d.ts +15 -0
- package/dist/src/errors/RatelimitError.d.ts.map +1 -0
- package/dist/src/errors/RatelimitError.js +18 -0
- package/dist/src/errors/RatelimitError.js.map +1 -0
- package/dist/src/{factories → functions}/channelFactory.d.ts +3 -2
- package/dist/src/functions/channelFactory.d.ts.map +1 -0
- package/dist/src/functions/channelFactory.js.map +1 -0
- package/dist/src/functions/errorsMapper.d.ts +14 -0
- package/dist/src/functions/errorsMapper.d.ts.map +1 -0
- package/dist/src/functions/errorsMapper.js +34 -0
- package/dist/src/functions/errorsMapper.js.map +1 -0
- package/dist/src/index.d.ts +78 -13
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +31 -14
- package/dist/src/index.js.map +1 -1
- package/dist/src/internals/AutocompleteInteraction.d.ts +6 -2
- package/dist/src/internals/AutocompleteInteraction.d.ts.map +1 -1
- package/dist/src/internals/AutocompleteInteraction.js +14 -12
- package/dist/src/internals/AutocompleteInteraction.js.map +1 -1
- package/dist/src/internals/ComponentHandler.d.ts +3 -3
- package/dist/src/internals/ComponentHandler.d.ts.map +1 -1
- package/dist/src/internals/ComponentHandler.js +6 -6
- package/dist/src/internals/ComponentHandler.js.map +1 -1
- package/dist/src/internals/EventHandler.d.ts +11 -0
- package/dist/src/internals/EventHandler.d.ts.map +1 -0
- package/dist/src/internals/EventHandler.js +18 -0
- package/dist/src/internals/EventHandler.js.map +1 -0
- package/dist/src/internals/ModalInteraction.d.ts +2 -3
- package/dist/src/internals/ModalInteraction.d.ts.map +1 -1
- package/dist/src/internals/ModalInteraction.js +2 -3
- package/dist/src/internals/ModalInteraction.js.map +1 -1
- package/dist/src/plugins/gateway/GatewayPlugin.d.ts +41 -0
- package/dist/src/plugins/gateway/GatewayPlugin.d.ts.map +1 -0
- package/dist/src/plugins/gateway/GatewayPlugin.js +249 -0
- package/dist/src/plugins/gateway/GatewayPlugin.js.map +1 -0
- package/dist/src/plugins/gateway/index.d.ts +6 -0
- package/dist/src/plugins/gateway/index.d.ts.map +1 -0
- package/dist/src/plugins/gateway/index.js +6 -0
- package/dist/src/plugins/gateway/index.js.map +1 -0
- package/dist/src/plugins/gateway/types.d.ts +62 -0
- package/dist/src/plugins/gateway/types.d.ts.map +1 -0
- package/dist/src/plugins/gateway/types.js +5 -0
- package/dist/src/plugins/gateway/types.js.map +1 -0
- package/dist/src/plugins/gateway/utils/heartbeat.d.ts +17 -0
- package/dist/src/plugins/gateway/utils/heartbeat.d.ts.map +1 -0
- package/dist/src/plugins/gateway/utils/heartbeat.js +28 -0
- package/dist/src/plugins/gateway/utils/heartbeat.js.map +1 -0
- package/dist/src/plugins/gateway/utils/monitor.d.ts +35 -0
- package/dist/src/plugins/gateway/utils/monitor.d.ts.map +1 -0
- package/dist/src/plugins/gateway/utils/monitor.js +79 -0
- package/dist/src/plugins/gateway/utils/monitor.js.map +1 -0
- package/dist/src/plugins/gateway/utils/payload.d.ts +21 -0
- package/dist/src/plugins/gateway/utils/payload.d.ts.map +1 -0
- package/dist/src/plugins/gateway/utils/payload.js +46 -0
- package/dist/src/plugins/gateway/utils/payload.js.map +1 -0
- package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.d.ts +26 -0
- package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.d.ts.map +1 -0
- package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.js +74 -0
- package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.js.map +1 -0
- package/dist/src/plugins/gateway-forwarder/index.d.ts +3 -0
- package/dist/src/plugins/gateway-forwarder/index.d.ts.map +1 -0
- package/dist/src/plugins/gateway-forwarder/index.js +3 -0
- package/dist/src/plugins/gateway-forwarder/index.js.map +1 -0
- package/dist/src/plugins/linked-roles/LinkedRoles.d.ts +24 -27
- package/dist/src/plugins/linked-roles/LinkedRoles.d.ts.map +1 -1
- package/dist/src/plugins/linked-roles/LinkedRoles.js +37 -28
- package/dist/src/plugins/linked-roles/LinkedRoles.js.map +1 -1
- package/dist/src/plugins/sharding/ShardingPlugin.d.ts +42 -0
- package/dist/src/plugins/sharding/ShardingPlugin.d.ts.map +1 -0
- package/dist/src/plugins/sharding/ShardingPlugin.js +110 -0
- package/dist/src/plugins/sharding/ShardingPlugin.js.map +1 -0
- package/dist/src/plugins/sharding/index.d.ts +3 -0
- package/dist/src/plugins/sharding/index.d.ts.map +1 -0
- package/dist/src/plugins/sharding/index.js +3 -0
- package/dist/src/plugins/sharding/index.js.map +1 -0
- package/dist/src/structures/DmChannel.d.ts +1 -1
- package/dist/src/structures/DmChannel.d.ts.map +1 -1
- package/dist/src/structures/Guild.d.ts +2 -1
- package/dist/src/structures/Guild.d.ts.map +1 -1
- package/dist/src/structures/Guild.js +3 -1
- package/dist/src/structures/Guild.js.map +1 -1
- package/dist/src/structures/Message.d.ts +10 -12
- package/dist/src/structures/Message.d.ts.map +1 -1
- package/dist/src/structures/Message.js +57 -8
- package/dist/src/structures/Message.js.map +1 -1
- package/dist/src/structures/Role.d.ts +2 -1
- package/dist/src/structures/Role.d.ts.map +1 -1
- package/dist/src/structures/Role.js +2 -0
- package/dist/src/structures/Role.js.map +1 -1
- package/dist/src/structures/User.d.ts +3 -2
- package/dist/src/structures/User.d.ts.map +1 -1
- package/dist/src/structures/User.js +2 -0
- package/dist/src/structures/User.js.map +1 -1
- package/dist/src/types/index.d.ts +67 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +2 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/listeners.d.ts +539 -0
- package/dist/src/types/listeners.d.ts.map +1 -0
- package/dist/src/types/listeners.js +12 -0
- package/dist/src/types/listeners.js.map +1 -0
- package/dist/src/utils.d.ts +3 -16
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +18 -1
- package/dist/src/utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -7
- package/dist/src/adapters/cloudflare/index.d.ts +0 -16
- package/dist/src/adapters/cloudflare/index.d.ts.map +0 -1
- package/dist/src/adapters/cloudflare/index.js +0 -17
- package/dist/src/adapters/cloudflare/index.js.map +0 -1
- package/dist/src/adapters/next/index.d.ts +0 -14
- package/dist/src/adapters/next/index.d.ts.map +0 -1
- package/dist/src/adapters/next/index.js +0 -17
- package/dist/src/adapters/next/index.js.map +0 -1
- package/dist/src/adapters/shared.d.ts +0 -10
- package/dist/src/adapters/shared.d.ts.map +0 -1
- package/dist/src/adapters/shared.js +0 -2
- package/dist/src/adapters/shared.js.map +0 -1
- package/dist/src/classes/Button.d.ts.map +0 -1
- package/dist/src/classes/Button.js.map +0 -1
- package/dist/src/classes/ChannelSelectMenu.d.ts.map +0 -1
- package/dist/src/classes/ChannelSelectMenu.js.map +0 -1
- package/dist/src/classes/MentionableSelectMenu.d.ts.map +0 -1
- package/dist/src/classes/MentionableSelectMenu.js.map +0 -1
- package/dist/src/classes/RoleSelectMenu.d.ts.map +0 -1
- package/dist/src/classes/RoleSelectMenu.js.map +0 -1
- package/dist/src/classes/Row.d.ts +0 -25
- package/dist/src/classes/Row.d.ts.map +0 -1
- package/dist/src/classes/Row.js.map +0 -1
- package/dist/src/classes/StringSelectMenu.d.ts.map +0 -1
- package/dist/src/classes/StringSelectMenu.js.map +0 -1
- package/dist/src/classes/TextInput.d.ts.map +0 -1
- package/dist/src/classes/TextInput.js.map +0 -1
- package/dist/src/classes/UserSelectMenu.d.ts.map +0 -1
- package/dist/src/classes/UserSelectMenu.js.map +0 -1
- package/dist/src/createHandle.d.ts +0 -20
- package/dist/src/createHandle.d.ts.map +0 -1
- package/dist/src/createHandle.js +0 -57
- package/dist/src/createHandle.js.map +0 -1
- package/dist/src/factories/channelFactory.d.ts.map +0 -1
- package/dist/src/factories/channelFactory.js.map +0 -1
- package/dist/src/types.d.ts +0 -37
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -2
- package/dist/src/types.js.map +0 -1
- /package/dist/src/{factories → functions}/channelFactory.js +0 -0
|
@@ -0,0 +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,oBAAoB,CAAA;AAElD,MAAM,MAAM,uBAAuB,GAAG;IACrC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;CACxC,CAAA;AAED,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;gBAET,IAAI,CAAC,EAAE;QAClB,cAAc,CAAC,EAAE,uBAAuB,CAAA;KACxC;IAKD;;OAEG;IACH,KAAK,UAAQ;IACb;;OAEG;IACH,SAAS,UAAQ;IAEjB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB,cAAc,EAAE,uBAAuB,GAAG,IAAI,CAAO;IAErD;;;;OAIG;IACI,QAAQ,GAAI,gBAAgB,OAAO,IAAI,CAAC,cAAc,YAO5D;IAED,QAAQ,CAAC,SAAS,EAAE,MAAM,8BAA8B,CAAA;CACxD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BaseComponent } from "./BaseComponent.js";
|
|
2
|
+
export class BaseMessageInteractiveComponent extends BaseComponent {
|
|
3
|
+
isV2 = false;
|
|
4
|
+
constructor(data) {
|
|
5
|
+
super();
|
|
6
|
+
if (data?.additionalData)
|
|
7
|
+
this.additionalData = data.additionalData;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Whether the component response should be automatically deferred
|
|
11
|
+
*/
|
|
12
|
+
defer = false;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the component response should be ephemeral
|
|
15
|
+
*/
|
|
16
|
+
ephemeral = false;
|
|
17
|
+
additionalData = null;
|
|
18
|
+
/**
|
|
19
|
+
* Create a custom ID to use for this component that embeds additional data that you want to be handed
|
|
20
|
+
* @param additionalData The additional data that you want to be passed in this component's custom ID
|
|
21
|
+
* @returns The custom ID to use
|
|
22
|
+
*/
|
|
23
|
+
createId = (additionalData) => {
|
|
24
|
+
if (!additionalData)
|
|
25
|
+
return this.customId;
|
|
26
|
+
// id:arg1=1;arg2=2
|
|
27
|
+
const id = `${this.customId}:${Object.entries(additionalData)
|
|
28
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
29
|
+
.join(";")}`;
|
|
30
|
+
return id;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=BaseMessageInteractiveComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseMessageInteractiveComponent.js","sourceRoot":"","sources":["../../../src/abstracts/BaseMessageInteractiveComponent.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAMlD,MAAM,OAAgB,+BAAgC,SAAQ,aAAa;IAUjE,IAAI,GAAG,KAAK,CAAA;IAErB,YAAY,IAEX;QACA,KAAK,EAAE,CAAA;QACP,IAAI,IAAI,EAAE,cAAc;YAAE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAA;IACpE,CAAC;IAED;;OAEG;IACH,KAAK,GAAG,KAAK,CAAA;IACb;;OAEG;IACH,SAAS,GAAG,KAAK,CAAA;IAOjB,cAAc,GAAmC,IAAI,CAAA;IAErD;;;;OAIG;IACI,QAAQ,GAAG,CAAC,cAA0C,EAAE,EAAE;QAChE,IAAI,CAAC,cAAc;YAAE,OAAO,IAAI,CAAC,QAAQ,CAAA;QACzC,mBAAmB;QACnB,MAAM,EAAE,GAAG,GAAG,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC;aAC3D,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;aACxC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;QACb,OAAO,EAAE,CAAA;IACV,CAAC,CAAA;CAGD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { APIComponentInModalActionRow, ComponentType } from "discord-api-types/v10";
|
|
2
|
+
import { BaseComponent } from "./BaseComponent.js";
|
|
3
|
+
import type { ComponentAdditionalData } from "./BaseMessageInteractiveComponent.js";
|
|
4
|
+
export declare abstract class BaseModalComponent extends BaseComponent {
|
|
5
|
+
abstract type: ComponentType.TextInput;
|
|
6
|
+
readonly isV2 = false;
|
|
7
|
+
constructor(data?: {
|
|
8
|
+
additionalData?: ComponentAdditionalData;
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* The custom ID of the component
|
|
12
|
+
*/
|
|
13
|
+
abstract customId: string;
|
|
14
|
+
additionalData: ComponentAdditionalData | null;
|
|
15
|
+
/**
|
|
16
|
+
* Create a custom ID to use for this component that embeds additional data that you want to be handed
|
|
17
|
+
* @param additionalData The additional data that you want to be passed in this component's custom ID
|
|
18
|
+
* @returns The custom ID to use
|
|
19
|
+
*/
|
|
20
|
+
createId: (additionalData: typeof this.additionalData) => string;
|
|
21
|
+
abstract serialize: () => APIComponentInModalActionRow;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=BaseModalComponent.d.ts.map
|
|
@@ -0,0 +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,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAA;AAEnF,8BAAsB,kBAAmB,SAAQ,aAAa;IAC7D,SAAkB,IAAI,EAAE,aAAa,CAAC,SAAS,CAAA;IAE/C,QAAQ,CAAC,IAAI,SAAQ;gBAET,IAAI,CAAC,EAAE;QAClB,cAAc,CAAC,EAAE,uBAAuB,CAAA;KACxC;IAKD;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB,cAAc,EAAE,uBAAuB,GAAG,IAAI,CAAO;IAErD;;;;OAIG;IACI,QAAQ,GAAI,gBAAgB,OAAO,IAAI,CAAC,cAAc,YAO5D;IAED,QAAQ,CAAC,SAAS,EAAE,MAAM,4BAA4B,CAAA;CACtD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BaseComponent } from "./BaseComponent.js";
|
|
2
|
+
export class BaseModalComponent extends BaseComponent {
|
|
3
|
+
isV2 = false;
|
|
4
|
+
constructor(data) {
|
|
5
|
+
super();
|
|
6
|
+
if (data?.additionalData)
|
|
7
|
+
this.additionalData = data.additionalData;
|
|
8
|
+
}
|
|
9
|
+
additionalData = null;
|
|
10
|
+
/**
|
|
11
|
+
* Create a custom ID to use for this component that embeds additional data that you want to be handed
|
|
12
|
+
* @param additionalData The additional data that you want to be passed in this component's custom ID
|
|
13
|
+
* @returns The custom ID to use
|
|
14
|
+
*/
|
|
15
|
+
createId = (additionalData) => {
|
|
16
|
+
if (!additionalData)
|
|
17
|
+
return this.customId;
|
|
18
|
+
// id:arg1=1;arg2=2
|
|
19
|
+
const id = `${this.customId}:${Object.entries(additionalData)
|
|
20
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
21
|
+
.join(";")}`;
|
|
22
|
+
return id;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=BaseModalComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseModalComponent.js","sourceRoot":"","sources":["../../../src/abstracts/BaseModalComponent.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGlD,MAAM,OAAgB,kBAAmB,SAAQ,aAAa;IAGpD,IAAI,GAAG,KAAK,CAAA;IAErB,YAAY,IAEX;QACA,KAAK,EAAE,CAAA;QACP,IAAI,IAAI,EAAE,cAAc;YAAE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAA;IACpE,CAAC;IAOD,cAAc,GAAmC,IAAI,CAAA;IAErD;;;;OAIG;IACI,QAAQ,GAAG,CAAC,cAA0C,EAAE,EAAE;QAChE,IAAI,CAAC,cAAc;YAAE,OAAO,IAAI,CAAC,QAAQ,CAAA;QACzC,mBAAmB;QACnB,MAAM,EAAE,GAAG,GAAG,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC;aAC3D,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;aACxC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;QACb,OAAO,EAAE,CAAA;IACV,CAAC,CAAA;CAGD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { APIGuildForumDefaultReactionEmoji, APIGuildForumTag, APIThreadOnlyChannel, ChannelType, SortOrderType } from "discord-api-types/v10";
|
|
2
|
-
import type { MessagePayload } from "../types.js";
|
|
2
|
+
import type { MessagePayload } from "../types/index.js";
|
|
3
3
|
import type { IfPartial } from "../utils.js";
|
|
4
4
|
import { BaseGuildChannel } from "./BaseGuildChannel.js";
|
|
5
5
|
export declare abstract class GuildThreadOnlyChannel<Type extends ChannelType.GuildForum | ChannelType.GuildMedia, IsPartial extends boolean = false> extends BaseGuildChannel<Type, IsPartial> {
|
|
@@ -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,
|
|
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,aAAa,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAExD,8BAAsB,sBAAsB,CAC3C,IAAI,SAAS,WAAW,CAAC,UAAU,GAAG,WAAW,CAAC,UAAU,EAC5D,SAAS,SAAS,OAAO,GAAG,KAAK,CAChC,SAAQ,gBAAgB,CAAC,IAAI,EAAE,SAAS,CAAC;IAClC,OAAO,EAAE,oBAAoB,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IAElD;;OAEG;IACH,IAAI,KAAK,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC,CAG/C;IAED;;OAEG;IACH,IAAI,0BAA0B,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC,CAGpE;IAED;;OAEG;IACH,IAAI,6BAA6B,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC,CAGvE;IAED;;OAEG;IACH,IAAI,aAAa,IAAI,SAAS,CAAC,SAAS,EAAE,gBAAgB,EAAE,CAAC,CAG5D;IAED;;OAEG;IACH,IAAI,oBAAoB,IAAI,SAAS,CACpC,SAAS,EACT,iCAAiC,GAAG,IAAI,CACxC,CAGA;IAED;;OAEG;IACH,IAAI,gBAAgB,IAAI,SAAS,CAAC,SAAS,EAAE,aAAa,GAAG,IAAI,CAAC,CAGjE;IAED;;;OAGG;IACY,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAMpC;;;;OAIG;IACG,UAAU,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAOxE"}
|
|
@@ -1,11 +1,46 @@
|
|
|
1
|
+
import type { Client } from "../classes/Client.js";
|
|
2
|
+
/**
|
|
3
|
+
* The base class for all plugins
|
|
4
|
+
*/
|
|
1
5
|
export declare abstract class Plugin {
|
|
2
|
-
|
|
6
|
+
/**
|
|
7
|
+
* An ID that identifies the plugin uniquely between all other used plugins in the Client
|
|
8
|
+
*/
|
|
9
|
+
protected abstract id: string;
|
|
10
|
+
/**
|
|
11
|
+
* Registers the client with this plugin
|
|
12
|
+
* @param client The client to register
|
|
13
|
+
*/
|
|
14
|
+
registerClient?(client: Client): Promise<void> | void;
|
|
15
|
+
/**
|
|
16
|
+
* Registers the routes of this plugin with the client
|
|
17
|
+
* @param client The client to register the routes with
|
|
18
|
+
*/
|
|
19
|
+
registerRoutes?(client: Client): Promise<void> | void;
|
|
3
20
|
}
|
|
4
21
|
export interface Route {
|
|
22
|
+
/**
|
|
23
|
+
* The HTTP method of the route
|
|
24
|
+
*/
|
|
5
25
|
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
26
|
+
/**
|
|
27
|
+
* The relative path of the route
|
|
28
|
+
*/
|
|
6
29
|
path: `/${string}`;
|
|
30
|
+
/**
|
|
31
|
+
* The handler function for the route
|
|
32
|
+
* @param req The request object
|
|
33
|
+
* @param ctx The context object
|
|
34
|
+
* @returns The response object or a promise that resolves to a response object
|
|
35
|
+
*/
|
|
7
36
|
handler(req: Request, ctx?: Context): Response | Promise<Response>;
|
|
37
|
+
/**
|
|
38
|
+
* Whether this route requires authentication
|
|
39
|
+
*/
|
|
8
40
|
protected?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Whether this route is disabled
|
|
43
|
+
*/
|
|
9
44
|
disabled?: boolean;
|
|
10
45
|
}
|
|
11
46
|
export interface Context {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../../src/abstracts/Plugin.ts"],"names":[],"mappings":"AAAA,8BAAsB,MAAM;IAC3B,MAAM,EAAE,
|
|
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,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IAC7B;;;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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plugin.js","sourceRoot":"","sources":["../../../src/abstracts/Plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Plugin.js","sourceRoot":"","sources":["../../../src/abstracts/Plugin.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAgB,MAAM;CAgB3B"}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import Bun from "bun";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
export type
|
|
2
|
+
import type { Client } from "../../index.js";
|
|
3
|
+
export type Server = Bun.Server;
|
|
4
|
+
export type ServerOptions = Omit<Bun.ServeOptions, "fetch">;
|
|
5
5
|
/**
|
|
6
|
-
* Creates a
|
|
7
|
-
* @param
|
|
8
|
-
* @param options
|
|
9
|
-
* @returns The
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* const server = createServer(handle, { ... })
|
|
13
|
-
* ```
|
|
6
|
+
* Creates a server for the client using Bun.serve
|
|
7
|
+
* @param client The Carbon client to create the server for
|
|
8
|
+
* @param options Additional options for the server
|
|
9
|
+
* @returns The Bun.Server instance
|
|
14
10
|
*/
|
|
15
|
-
export declare function createServer(
|
|
11
|
+
export declare function createServer(client: Client, options: ServerOptions): Server;
|
|
16
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/adapters/bun/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/adapters/bun/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAG5C,MAAM,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAA;AAC/B,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;AAE3D;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CAM3E"}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import Bun from "bun";
|
|
2
|
+
import { createHandler } from "../fetch/index.js";
|
|
2
3
|
/**
|
|
3
|
-
* Creates a
|
|
4
|
-
* @param
|
|
5
|
-
* @param options
|
|
6
|
-
* @returns The
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* const server = createServer(handle, { ... })
|
|
10
|
-
* ```
|
|
4
|
+
* Creates a server for the client using Bun.serve
|
|
5
|
+
* @param client The Carbon client to create the server for
|
|
6
|
+
* @param options Additional options for the server
|
|
7
|
+
* @returns The Bun.Server instance
|
|
11
8
|
*/
|
|
12
|
-
export function createServer(
|
|
13
|
-
const fetch =
|
|
9
|
+
export function createServer(client, options) {
|
|
10
|
+
const fetch = createHandler(client);
|
|
14
11
|
return Bun.serve({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
hostname: options.hostname
|
|
12
|
+
...options,
|
|
13
|
+
fetch: (r) => fetch(r, {})
|
|
18
14
|
});
|
|
19
15
|
}
|
|
20
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/adapters/bun/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/adapters/bun/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AAErB,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAKjD;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAAc,EAAE,OAAsB;IAClE,MAAM,KAAK,GAAG,aAAa,CAAC,MAAM,CAAC,CAAA;IACnC,OAAO,GAAG,CAAC,KAAK,CAAC;QAChB,GAAG,OAAO;QACV,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;KAC1B,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Context } from "../../abstracts/Plugin.js";
|
|
2
|
+
import type { Client } from "../../classes/Client.js";
|
|
3
|
+
export type Handler = (req: Request, ctx: Context) => Promise<Response>;
|
|
4
|
+
/**
|
|
5
|
+
* Creates a fetch handler function for the clients routes
|
|
6
|
+
* @param client The client to create the handler for
|
|
7
|
+
* @returns The handler function
|
|
8
|
+
*/
|
|
9
|
+
export declare function createHandler(client: Client): Handler;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/adapters/fetch/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAS,MAAM,2BAA2B,CAAA;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAErD,MAAM,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEvE;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAiCrD"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a fetch handler function for the clients routes
|
|
3
|
+
* @param client The client to create the handler for
|
|
4
|
+
* @returns The handler function
|
|
5
|
+
*/
|
|
6
|
+
export function createHandler(client) {
|
|
7
|
+
return async (req, ctx) => {
|
|
8
|
+
const method = req.method;
|
|
9
|
+
const url = new URL(req.url, "http://localhost");
|
|
10
|
+
const pathname = //
|
|
11
|
+
resolveRequestPathname(new URL(client.options.baseUrl), url);
|
|
12
|
+
if (!pathname)
|
|
13
|
+
return new Response("Not Found", { status: 404 });
|
|
14
|
+
const matchedRoutesByPath = //
|
|
15
|
+
client.routes.filter((r) => r.path === pathname && !r.disabled);
|
|
16
|
+
const matchedRoutesByMethod = //
|
|
17
|
+
matchedRoutesByPath.filter((r) => r.method === method);
|
|
18
|
+
if (matchedRoutesByMethod.length === 0) {
|
|
19
|
+
if (matchedRoutesByPath.length > 0)
|
|
20
|
+
return new Response("Method Not Allowed", { status: 405 });
|
|
21
|
+
return new Response("Not Found", { status: 404 });
|
|
22
|
+
}
|
|
23
|
+
// Use the last matched route to allow for overriding
|
|
24
|
+
const route = matchedRoutesByMethod.at(-1);
|
|
25
|
+
const passedSecret = url.searchParams.get("secret");
|
|
26
|
+
if (route.protected && client.options.deploySecret !== passedSecret)
|
|
27
|
+
return new Response("Unauthorized", { status: 401 });
|
|
28
|
+
try {
|
|
29
|
+
return await route.handler(req, ctx);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.error(error);
|
|
33
|
+
return new Response("Internal Server Error", { status: 500 });
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function resolveRequestPathname(baseUrl, reqUrl) {
|
|
38
|
+
// Need to use pathname only due to host name being different in Cloudflare Tunnel
|
|
39
|
+
const basePathname = baseUrl.pathname.replace(/\/$/, "");
|
|
40
|
+
const reqPathname = reqUrl.pathname.replace(/\/$/, "");
|
|
41
|
+
if (!reqPathname.startsWith(basePathname))
|
|
42
|
+
return null;
|
|
43
|
+
return reqPathname.slice(basePathname.length);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/adapters/fetch/index.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,MAAc;IAC3C,OAAO,KAAK,EAAE,GAAY,EAAE,GAAY,EAAE,EAAE;QAC3C,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAA;QACzB,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAA;QAChD,MAAM,QAAQ,GAAG,EAAE;SAClB,sBAAsB,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,CAAA;QAC7D,IAAI,CAAC,QAAQ;YAAE,OAAO,IAAI,QAAQ,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;QAEhE,MAAM,mBAAmB,GAAG,EAAE;SAC7B,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;QAChE,MAAM,qBAAqB,GAAG,EAAE;SAC/B,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAA;QAEvD,IAAI,qBAAqB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxC,IAAI,mBAAmB,CAAC,MAAM,GAAG,CAAC;gBACjC,OAAO,IAAI,QAAQ,CAAC,oBAAoB,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;YAC3D,OAAO,IAAI,QAAQ,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;QAClD,CAAC;QAED,qDAAqD;QACrD,MAAM,KAAK,GAAG,qBAAqB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAU,CAAA;QAEnD,MAAM,YAAY,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QACnD,IAAI,KAAK,CAAC,SAAS,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,KAAK,YAAY;YAClE,OAAO,IAAI,QAAQ,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;QAErD,IAAI,CAAC;YACJ,OAAO,MAAM,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;QACrC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;YACpB,OAAO,IAAI,QAAQ,CAAC,uBAAuB,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;QAC9D,CAAC;IACF,CAAC,CAAA;AACF,CAAC;AAED,SAAS,sBAAsB,CAAC,OAAY,EAAE,MAAW;IACxD,kFAAkF;IAClF,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IACxD,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IACtD,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,YAAY,CAAC;QAAE,OAAO,IAAI,CAAA;IACtD,OAAO,WAAW,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAA;AAC9C,CAAC"}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import * as Hono from "@hono/node-server";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
export type
|
|
2
|
+
import type { Client } from "../../index.js";
|
|
3
|
+
export type Server = Hono.ServerType;
|
|
4
|
+
export type ServerOptions = Omit<Parameters<typeof Hono.serve>[0], "fetch">;
|
|
5
5
|
/**
|
|
6
|
-
* Creates a
|
|
7
|
-
* @param
|
|
8
|
-
* @param options
|
|
9
|
-
* @returns The
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* const server = createServer(handle, { ... })
|
|
13
|
-
* ```
|
|
6
|
+
* Creates a server for the client using Hono.serve under the hood
|
|
7
|
+
* @param client The Carbon client to create the server for
|
|
8
|
+
* @param options Additional options for the server
|
|
9
|
+
* @returns The server instance
|
|
14
10
|
*/
|
|
15
|
-
export declare function createServer(
|
|
11
|
+
export declare function createServer(client: Client, options: ServerOptions): Server;
|
|
16
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/adapters/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAA;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/adapters/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAA;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAG5C,MAAM,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAA;AACpC,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;AAE3E;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CAO3E"}
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import * as Hono from "@hono/node-server";
|
|
2
|
+
import { createHandler } from "../fetch/index.js";
|
|
2
3
|
/**
|
|
3
|
-
* Creates a
|
|
4
|
-
* @param
|
|
5
|
-
* @param options
|
|
6
|
-
* @returns The
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* const server = createServer(handle, { ... })
|
|
10
|
-
* ```
|
|
4
|
+
* Creates a server for the client using Hono.serve under the hood
|
|
5
|
+
* @param client The Carbon client to create the server for
|
|
6
|
+
* @param options Additional options for the server
|
|
7
|
+
* @returns The server instance
|
|
11
8
|
*/
|
|
12
|
-
export function createServer(
|
|
13
|
-
const fetch =
|
|
9
|
+
export function createServer(client, options) {
|
|
10
|
+
const fetch = createHandler(client);
|
|
14
11
|
return Hono.serve({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
// Weird type issue with options.createServer ??
|
|
13
|
+
...options,
|
|
14
|
+
fetch: (r) => fetch(r, {})
|
|
18
15
|
});
|
|
19
16
|
}
|
|
20
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/adapters/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/adapters/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAA;AAEzC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAKjD;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAAc,EAAE,OAAsB;IAClE,MAAM,KAAK,GAAG,aAAa,CAAC,MAAM,CAAC,CAAA;IACnC,OAAO,IAAI,CAAC,KAAK,CAAC;QACjB,gDAAgD;QAChD,GAAI,OAAkB;QACtB,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;KAC1B,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import { RequestClient, type RequestClientOptions } from "@buape/carbon-request";
|
|
2
1
|
import type { BaseCommand } from "../abstracts/BaseCommand.js";
|
|
3
|
-
import
|
|
2
|
+
import type { BaseListener } from "../abstracts/BaseListener.js";
|
|
3
|
+
import type { Context, Plugin, Route } from "../abstracts/Plugin.js";
|
|
4
4
|
import { CommandHandler } from "../internals/CommandHandler.js";
|
|
5
5
|
import { ComponentHandler } from "../internals/ComponentHandler.js";
|
|
6
|
+
import { EventHandler } from "../internals/EventHandler.js";
|
|
6
7
|
import { ModalHandler } from "../internals/ModalHandler.js";
|
|
7
8
|
import { Guild } from "../structures/Guild.js";
|
|
8
9
|
import { GuildMember } from "../structures/GuildMember.js";
|
|
10
|
+
import { Message } from "../structures/Message.js";
|
|
9
11
|
import { Role } from "../structures/Role.js";
|
|
10
12
|
import { User } from "../structures/User.js";
|
|
13
|
+
import { RequestClient, type RequestClientOptions } from "./RequestClient.js";
|
|
11
14
|
/**
|
|
12
15
|
* The options used for initializing the client
|
|
13
16
|
*/
|
|
14
17
|
export interface ClientOptions {
|
|
18
|
+
/**
|
|
19
|
+
* The base URL of the app
|
|
20
|
+
*/
|
|
21
|
+
baseUrl: string;
|
|
15
22
|
/**
|
|
16
23
|
* The client ID of the app
|
|
17
24
|
*/
|
|
@@ -22,8 +29,9 @@ export interface ClientOptions {
|
|
|
22
29
|
deploySecret?: string;
|
|
23
30
|
/**
|
|
24
31
|
* The public key of the app, used for interaction verification
|
|
32
|
+
* Can be a single key or an array of keys
|
|
25
33
|
*/
|
|
26
|
-
publicKey: string;
|
|
34
|
+
publicKey: string | string[];
|
|
27
35
|
/**
|
|
28
36
|
* The token of the bot
|
|
29
37
|
*/
|
|
@@ -49,15 +57,28 @@ export interface ClientOptions {
|
|
|
49
57
|
*/
|
|
50
58
|
disableDeployRoute?: boolean;
|
|
51
59
|
/**
|
|
52
|
-
* Whether the interactions route should
|
|
60
|
+
* Whether the interactions route should be disabled
|
|
53
61
|
* @default false
|
|
54
62
|
*/
|
|
55
63
|
disableInteractionsRoute?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Whether the events route should be disabled
|
|
66
|
+
* @default false
|
|
67
|
+
*/
|
|
68
|
+
disableEventsRoute?: boolean;
|
|
56
69
|
}
|
|
57
70
|
/**
|
|
58
71
|
* The main client used to interact with Discord
|
|
59
72
|
*/
|
|
60
|
-
export declare class Client
|
|
73
|
+
export declare class Client {
|
|
74
|
+
/**
|
|
75
|
+
* The routes that the client will handle
|
|
76
|
+
*/
|
|
77
|
+
routes: Route[];
|
|
78
|
+
/**
|
|
79
|
+
* The plugins that the client has registered
|
|
80
|
+
*/
|
|
81
|
+
plugins: Plugin[];
|
|
61
82
|
/**
|
|
62
83
|
* The options used to initialize the client
|
|
63
84
|
*/
|
|
@@ -66,6 +87,10 @@ export declare class Client extends Plugin {
|
|
|
66
87
|
* The commands that the client has registered
|
|
67
88
|
*/
|
|
68
89
|
commands: BaseCommand[];
|
|
90
|
+
/**
|
|
91
|
+
* The event listeners that the client has registered
|
|
92
|
+
*/
|
|
93
|
+
listeners: BaseListener[];
|
|
69
94
|
/**
|
|
70
95
|
* The rest client used to interact with the Discord API
|
|
71
96
|
*/
|
|
@@ -85,18 +110,33 @@ export declare class Client extends Plugin {
|
|
|
85
110
|
* @internal
|
|
86
111
|
*/
|
|
87
112
|
modalHandler: ModalHandler;
|
|
113
|
+
/**
|
|
114
|
+
* The handler for events sent from Discord
|
|
115
|
+
* @internal
|
|
116
|
+
*/
|
|
117
|
+
eventHandler: EventHandler;
|
|
88
118
|
/**
|
|
89
119
|
* Creates a new client
|
|
90
120
|
* @param options The options used to initialize the client
|
|
91
|
-
* @param
|
|
121
|
+
* @param handlers The handlers that the client has registered
|
|
122
|
+
* @param plugins The plugins that the client should use
|
|
92
123
|
*/
|
|
93
|
-
constructor(options: ClientOptions,
|
|
124
|
+
constructor(options: ClientOptions, handlers: {
|
|
125
|
+
commands?: BaseCommand[];
|
|
126
|
+
listeners?: BaseListener[];
|
|
127
|
+
}, plugins?: Plugin[]);
|
|
94
128
|
private appendRoutes;
|
|
95
129
|
/**
|
|
96
130
|
* Handle a request to deploy the commands to Discord
|
|
97
131
|
* @returns A response
|
|
98
132
|
*/
|
|
99
133
|
handleDeployRequest(): Promise<Response>;
|
|
134
|
+
/**
|
|
135
|
+
* Handle an interaction request from Discord
|
|
136
|
+
* @param req The request to handle
|
|
137
|
+
* @returns A response
|
|
138
|
+
*/
|
|
139
|
+
handleEventsRequest(req: Request): Promise<Response>;
|
|
100
140
|
/**
|
|
101
141
|
* Handle an interaction request from Discord
|
|
102
142
|
* @param req The request to handle
|
|
@@ -105,10 +145,10 @@ export declare class Client extends Plugin {
|
|
|
105
145
|
*/
|
|
106
146
|
handleInteractionsRequest(req: Request, ctx: Context): Promise<Response>;
|
|
107
147
|
/**
|
|
108
|
-
* Validate
|
|
148
|
+
* Validate a request from Discord
|
|
109
149
|
* @param req The request to validate
|
|
110
150
|
*/
|
|
111
|
-
private
|
|
151
|
+
private validateDiscordRequest;
|
|
112
152
|
/**
|
|
113
153
|
* Fetch a user from the Discord API
|
|
114
154
|
* @param id The ID of the user to fetch
|
|
@@ -140,6 +180,13 @@ export declare class Client extends Plugin {
|
|
|
140
180
|
* @returns The member data
|
|
141
181
|
*/
|
|
142
182
|
fetchMember(guildId: string, id: string): Promise<GuildMember<false, true>>;
|
|
183
|
+
/**
|
|
184
|
+
* Fetch a message from the Discord API
|
|
185
|
+
* @param channelId The ID of the channel the message is in
|
|
186
|
+
* @param messageId The ID of the message to fetch
|
|
187
|
+
* @returns The message data
|
|
188
|
+
*/
|
|
189
|
+
fetchMessage(channelId: string, messageId: string): Promise<Message<false>>;
|
|
143
190
|
}
|
|
144
191
|
/**
|
|
145
192
|
* @hidden
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../../src/classes/Client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../../src/classes/Client.ts"],"names":[],"mappings":"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"}
|