GiveawayBot uses a file-based event system that mirrors its command handler: drop a file intoDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/resynceddesign/giveawaybot/llms.txt
Use this file to discover all available pages before exploring further.
src/events/, build, and restart. Every Discord.js gateway event is available, and you can add as many handlers as you need without modifying any core files.
How the handler works
src/handlers/Event.ts runs at startup and uses readdirSync to scan the compiled build/events/ directory. For each .js file it finds, it imports the default export and registers it with the Discord.js client:
once is true, the handler uses client.once so it fires only the first time the event occurs. Otherwise it uses client.on for every occurrence.
The BotEvent interface
Every event file must export a default object satisfying theBotEvent interface from src/types.d.ts:
name— any Discord.jsEventsenum value or its string equivalent (e.g."ready","messageCreate").once— whentrue, the handler fires exactly once and is removed automatically. Defaults tofalse.execute— the function that runs when the event fires. Argument types match the Discord.js event signature.
Built-in events
GiveawayBot ships with three event handlers insrc/events/:
| File | Event | once | Purpose |
|---|---|---|---|
ready.ts | ready | true | Sets the bot’s activity status and starts the 1-second giveaway check interval via setInterval(() => processGiveaways(client), 1000) |
interactionCreate.ts | interactionCreate | — | Routes slash commands (with cooldown enforcement), autocomplete, modal submits, and button clicks (giveaway entry handling) |
guildCreate.ts | guildCreate | — | Calls GuildManager.createGuild() to insert a new SQLite row with default settings whenever the bot joins a server |
Adding a custom event
Create a new file in src/events/
Create
src/events/myEvent.ts. The filename does not need to match the event name, but keeping them consistent makes the codebase easier to navigate.Implement the BotEvent interface
Export a default object that satisfies For a
BotEvent. Here is an example that logs a message to the console whenever the bot is removed from a server:messageCreate handler, the signature would be:Use
once: true only for events that should fire a single time per process lifetime — typically ready. For recurring events like messageCreate or guildMemberAdd, omit once (or set it to false) so the handler stays registered and fires every time the event occurs.