Listener

Create a listener

Like the commands, it is recommended to use the CLI to correctly generate the body of the listener.

CLI pattern

By typing bot add listener -h you will get this following information.

bot add listener <event>

Positionals:
  event      # listener event name                                      [required]

Options:
  -n, --name # The name of listener file                           [default: null]
  --version  # Show version number                                       [boolean]
  --help     # Show help                                                 [boolean]

Example

For a "ready" listener that displays Hello World in the console, type the following command.

bot add listener "ready" --name "helloWorld"

Then, the src/listeners/helloWorld.ts file will be ready to be implemented.

You can use the default naming pattern {category or behavior}.{event name} to organize your listeners. Example:

bot add listener "ready" --name "hellowWorld.ready"

Additional events

For the proper functioning of the framework, some additional events have been added. Here is a list.

interface MoreClientEvents {
  /** Already existing event. I just added the typing */
  raw: [packet: GatewayDispatchPayload]
  
  /** Called after the end of all "ready" listeners */
  afterReady: [Client<true>]
}

Last updated