This repository was archived by the owner on Aug 22, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 41
Client Payload Injection
Adam Pine edited this page May 18, 2021
·
2 revisions
For each event a list of arguments is injected in your decorated method, you can type this list thanks to the ArgsOf<Event> type provided by discord.ts.
You also receive other useful arguments after that:
- The event payload (
ArgsOf<Event>) - The
Clientinstance - The guards payload
You should use JS desctructuring for
ArgsOf<Event>like in this example
import {
Discord,
On,
Client,
ArgsOf
} from "@typeit/discord";
@Discord()
abstract class AppDiscord {
@On("message")
private onMessage(
[message]: ArgsOf<"message">, // Type message automatically
client: Client, // Client instance injected here,
guardPayload: any
) {
// ...
}
}