@minesa-org/mini-interaction 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +130 -20
- package/dist/index.d.ts +1 -8
- package/dist/index.js +1 -4
- package/dist/types/InteractionFlags.d.ts +0 -4
- package/dist/types/InteractionFlags.js +0 -4
- package/dist/utils/ModalSubmitInteraction.js +5 -2
- package/package.json +1 -1
- package/dist/clients/MiniInteraction.d.ts +0 -441
- package/dist/clients/MiniInteraction.js +0 -1731
- package/dist/compat/LegacyMiniInteractionAdapter.d.ts +0 -19
- package/dist/compat/LegacyMiniInteractionAdapter.js +0 -23
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { APIInteractionResponse } from 'discord-api-types/v10';
|
|
2
|
-
import { DiscordRestClient } from '../core/http/DiscordRestClient.js';
|
|
3
|
-
import { InteractionRouter } from '../router/InteractionRouter.js';
|
|
4
|
-
export type LegacyAdapterOptions = {
|
|
5
|
-
publicKey: string;
|
|
6
|
-
applicationId: string;
|
|
7
|
-
token: string;
|
|
8
|
-
};
|
|
9
|
-
export declare class LegacyMiniInteractionAdapter {
|
|
10
|
-
private readonly options;
|
|
11
|
-
readonly router: InteractionRouter;
|
|
12
|
-
readonly rest: DiscordRestClient;
|
|
13
|
-
constructor(options: LegacyAdapterOptions);
|
|
14
|
-
handleRequest(input: {
|
|
15
|
-
body: string;
|
|
16
|
-
signature: string;
|
|
17
|
-
timestamp: string;
|
|
18
|
-
}): Promise<APIInteractionResponse>;
|
|
19
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { InteractionType } from 'discord-api-types/v10';
|
|
2
|
-
import { DiscordRestClient } from '../core/http/DiscordRestClient.js';
|
|
3
|
-
import { InteractionContext } from '../core/interactions/InteractionContext.js';
|
|
4
|
-
import { verifyAndParseInteraction } from '../core/interactions/InteractionVerifier.js';
|
|
5
|
-
import { InteractionRouter } from '../router/InteractionRouter.js';
|
|
6
|
-
export class LegacyMiniInteractionAdapter {
|
|
7
|
-
options;
|
|
8
|
-
router = new InteractionRouter();
|
|
9
|
-
rest;
|
|
10
|
-
constructor(options) {
|
|
11
|
-
this.options = options;
|
|
12
|
-
this.rest = new DiscordRestClient({ applicationId: options.applicationId, token: options.token });
|
|
13
|
-
}
|
|
14
|
-
async handleRequest(input) {
|
|
15
|
-
const interaction = await verifyAndParseInteraction({ ...input, publicKey: this.options.publicKey });
|
|
16
|
-
if (interaction.type === InteractionType.Ping) {
|
|
17
|
-
return { type: 1 };
|
|
18
|
-
}
|
|
19
|
-
const ctx = new InteractionContext({ interaction, rest: this.rest, autoAck: { enabled: true } });
|
|
20
|
-
const response = await this.router.dispatch(interaction, ctx);
|
|
21
|
-
return response ?? ctx.deferReply();
|
|
22
|
-
}
|
|
23
|
-
}
|