This template has strict typing, the flow for making a command or an event is the following.
Events
Create a new file inside the events folder, or any folder inside, the file inclusion is recursive, and add the following:
You must export a class that extends EventHandler, otherwise it will be ignored, the eventType getter is the name of the event to handle and the invoke method (can be async) is the event handler, this will run when the event is fired.
You have access to the client from this.client and for any event parameters add them to the invoke function.
Create a new file inside the commands folder, again, it's recursive. Then include the following:
You must export a class that extends SlashCommand, otherwise it will be ignored, the build getter should return the SlashCommandBuilder instance for this command and the run method is the handler for this command.
You have access to this.context as the command context and this.client as the client that executed this command.
export default class extends SlashCommand {
public get build(): SlashCommandBuilder {
return new SlashCommandBuilder()
.setName("test")
.setDescription("yes this is a test!");
}
public async run(): Promise<void> {
await this.context!.reply("yes!")
}
}
Template
This template has strict typing, the flow for making a command or an event is the following.
Events
Create a new file inside the
events
folder, or any folder inside, the file inclusion is recursive, and add the following:You must export a class that extends
EventHandler
, otherwise it will be ignored, theeventType
getter is the name of the event to handle and theinvoke
method (can be async) is the event handler, this will run when the event is fired.You have access to the client from
this.client
and for any event parameters add them to theinvoke
function.Commands
Create a new file inside the
commands
folder, again, it's recursive. Then include the following:You must export a class that extends
SlashCommand
, otherwise it will be ignored, thebuild
getter should return theSlashCommandBuilder
instance for this command and therun
method is the handler for this command.You have access to
this.context
as the command context andthis.client
as the client that executed this command.