Bootstrap App
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 bootstrapApp
function is executed to connect the discord bot application.
In this topic you will see some interesting options for this function.
Work directory (workdir)
This option must receive the name of the current directory, when running the project under development this directory will be src
, but when the project is built it will be build
.
This option is important so that files from the discord folder can be imported before the bot starts.
Directories
You can pass an array of paths relative to workdir
that you want to be imported before the bot starts.
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.
Command options (commands)
You can set an array of guild ids to register the commands, so instead of registering the commands globally in the application (which is the default behavior of the base), the commands will only be registered in the guilds whose ids were passed to the option.
It is recommended to set environment variables for guild ids.
Responder options
You can set a default execution for when the customId of a bot component or modal is used and there is no Responder for it.
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.