Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

@On @Once

Adam Pine edited this page May 18, 2021 · 3 revisions

We can now declare methods that will be executed whenever a Discord event is triggered.
Our methods must be decorated with the @On(event: string) or @Once(event: string) decorator.
That's simple, when the event is triggered, the method is called:

import {
  Discord,
  On,
  Once
} from "@typeit/discord";

@Discord()
abstract class AppDiscord {
  @On("message")
  private onMessage() {
    // ...
  }

  @Once("ready")
  private onReady() {
    // ...
  }
}