Prefix Commands
Setting Up Prefix Commands
1. Import Required Functions
In your index.js
file (or wherever you initialize your bot), start by importing the necessary functions from the mvk-project
package:
2. Create and Configure Your Bot Client
Use the startBot
function to create and configure your bot client. This function sets up the bot with your token, intents, prefix, and an optional console log message:
3. Load Prefix Commands
To load and manage prefix commands, use the loadCommands
function. This function will load all your prefix-based commands from a specified directory. Make sure to pass the client
instance to the function:
This step ensures that all your prefix commands are registered and ready to be used. The loadCommands
function looks for command files in the provided directory (./prefix_commands
in this case) and integrates them into your bot.
4. Start Your Bot
Finally, start your bot by running your index.js
file using Node.js:
Your bot will initialize, load the prefix commands, and begin operating with the configurations you’ve set.
Test with a Basic Ping Command
To test if everything is working correctly, let's start with a basic ping command. The functions shown below are just for demonstration purposes; you will learn more about them later on.
In this example:
Replace
client.ws.ping
with the actual function or property you use to get the bot's ping.The
sendMessage
function is used to send a message to the channel with the ping information.
You can now test this command to see if your bot responds with the ping value.
Last updated