Bootstrap
Initial discord bot project function
Entry point
The index.ts
file in the src
folder is the entry point of this project, it is where the bootstrap
function is executed to connect the discord bot application.
In this topic you will see some interesting options for this function.
Meta
This option should receive the import.meta of the current file. When running the project in development, the import.meta directory will be src
, but when the project is built it will be build
.
This option is important so that the files in the discord folder can be imported before the bot starts.
Directories
You can pass an array of paths relative to the current folder that you want to be imported before the bot starts.
Any nested subfolders of the directories you pass in this property will also be loaded, no matter how deep.
With this you can create commands
, events
and responders
within these directories and they will be loaded before the bot starts.
Load logs (loadLogs)
It is possible to disable the load logs of structures in this base by setting false in the loadLogs
option of the bootstrapApp
function.
When ready (whenReady)
The base already has a listener for the bot's ready
event, if you don't want to create a new listener for this, you can use it by just passing a function to this option.
Before load
You can run code before the directories are loaded. Receive the client
not ready yet.