Bot.ts
  • Introduction
  • Installation
  • Configuration
  • Migrate to v9
  • Troubleshooting
  • Command line
    • CLI Overview
    • Docker
    • Build
    • Start
    • Format
    • Lint
    • Test
    • Update
    • Readme
    • Final
  • Usage
    • Command
    • Listener
    • Button
    • Namespace
    • Cron
    • Logger
    • Paginator
    • Database
    • Caching
    • Custom types
  • Native commands
    • Eval
    • Help
    • Database
    • Terminal
    • Turn
    • Info
  • Command examples
    • Prefix
  • Utilities
    • Texts
    • Paths and URLs
    • Dates and durations
    • Special events
    • Other
  • Deployment
    • Production
    • Development
  • Contributing
    • Regulations
    • Coding Style
  • Annexes
    • Discord Support
Powered by GitBook
On this page
  • messageEmitter
  • onceMessage Function
  • Parameters:
  • Example:
  • More default Client events
  • Example:

Was this helpful?

  1. Utilities

Special events

This section outlines the utilities for managing special events using a custom event emitter in Discord. It allows you to create and manage events efficiently without relying on the default client eve

messageEmitter

An instance of EventEmitter specifically designed to handle message events.


onceMessage Function

The onceMessage function allows you to register a callback for a specific event that will only be executed once. After it is triggered, it will be removed automatically.

Parameters:

  • emitter: The specific event emitter (from EventEmitters).

  • cb: The callback function to execute when the event is emitted.

Example:

onceMessage("messageCreate", (message) => {
  console.log(`Message received: ${message.content}`)
})

More default Client events

The MoreClientEvents interface extends the default Discord client events by adding custom events, such as raw and afterReady.

Example:

export interface MoreClientEvents {
  raw: [packet: apiTypes.GatewayDispatchPayload]
  afterReady: [discord.Client<true>] // Wait for all "ready" asyncronous listeners before triggering
}

PreviousDates and durationsNextOther

Last updated 6 months ago

Was this helpful?