Warning
Outdated project! If you want, you can continue to develop it, but I won't at the moment!
A template for discord.js apps.
To use this template, fork or clone repository and since it's a template, you can just start building your application.
Components handle message component interactions, as well as modal interactions.
In our example structure, we have a sub-folder in our src
folder named components
. All *.js
files inside are treated as component files. I usually prefer to have a sub-folder for utility files in there as well.
Component files have to default export
an object with the properties prefix
and run
.
Component prefixes are strings. They are built like a URL with query parameters.
The parameters don't have the usual key=value
structure. They're also built like a path.
Fun fact: Component prefixes match the following regex:
^[^/]+(?:\/[^/]+)*(?:\?(?:[^/]+(?:\/[^/]+)*))?
- Simple component:
help
- Sub component (e.g. for a specific help-page):
help/commands
- Component with param (e.g. for a pagination system you have to pass the current page):
some/component/page?2
- Everything:
foo/bar?fizz/buzz/123
This should be an async function that takes one parameter as the Interaction.
default export {
prefix: "help",
async run(ctx) {
await ctx.reply("beep");
},
}
See the article of the djsCommandHelper
for more information on the command file itself.
Basically, all *.js
files inside are treated as command files. I usually prefer to have a sub-folder utils
for utility files in there as well.
Tip
If you have complex subcommands/subcommand groups, put them inside the utility folder and import them in the base command file.
Events are dynamically loaded. In this example we have an events
sub-folder in our src
directory.
Since events can have multiple listeners and sometimes one event file is a bit too complicated, we make another folder for every event there is inside the events
folder, which houses files that export default
a function that acts as the event listener.
Note
An overview of supported events can be found here: Click
You are free to contribute to this template. Just fork the repository and create a pull request.