Quick Start
Here is a basic example of how to setup and configure discord-features-handler. When calling the constructor you can pass in the discord client object and regular object that configures discord-features-handler to how you want. Basic folder structure layout:
Here is a simple example with only the essentials to get a bot up and running:
DiscordFeaturesHandler(client, options)
client
true
options
Object
true
options properties
The object parameter should contain the follow keys. The value of the keys are based off the type stated below.
When setting up the bot you must always set this in property value: directories:{ main: __diranme } This set the local path to your index.js file. This is a requirement in order for this handler to run.
directories.main
folder path
true
null
config
path to config file
true
"./config"
directories.commands
String
false
commands
directories.events
String
false
events
directories.modules
String
false
modules
builtin_files
Object
false
{...}
filesToExcludeInHandlers
Object
false
{...}
View DiscordFeaturesHandler Setup Page for more details
Create Commands
Follow the folder structure and create sub folders inside your command folder. Name these sub-folders as a category name for your command files. Afterwards, create the command files inside those sub-folders. All commands have the following:
name
string
true
name of command
description
string
true
description of command
aliases
Array<string>
true
aliases of the command, you must set []
guildOnly
boolean
false
if command is guild only (not a DM command)
permission
Number
true
Permission level required to use command
minArgs
Number
true
Minimum number of arguments required for command execution
maxArgs
Number
false
Maximum number of arguments required for command execution
usage
string
true
Show how to use the command call
execute(message, args, client, level)
Function
true
Functionality and response of the command call
execute(message, args, client, level)
message
true
args
Array<string>
false
client
false
level
User's Permission Level
false
View Commands Setup Page for more details
Creating Slash Commands
You will need to set the command properties mentioned above and the following:
data
SlashCommandBuilder
true
slash command setup
interactionReply(interaction, client, level)
async Function
true
View Slash Commands Setup Page for more details
Creating Events
Events file are created inside the event directory folder.
name
string
true
once
boolean
false
if you want the event to run once on first trigger
execute(client, params...)
Function
true
functionality and response when the event is triggered
View Events Setup Page for more details
Creating Modules
These are your feature files and you can define anything you want in here and is an optional folder that you can use. If using JavaScript they are module.exports file and for TypeScript they are exports defauilt files. The only parameter is DiscordJS Client is that you can use if required for your feature.
If using TypeScript, create your modules file with exports default instead of module.exports.
Last updated