Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
2

How do I make / commands node.js

Jasonkingtou
Jasonkingtou

I dont know how to make / commands so i need help

1 year ago

Voters

Comments

TopNew
1
mumuji1723
mumuji1723

Actually, it can be easier. What you do is make a folder with all commands called "commands", then create
a file called deploy-commands.js Now, to create a command, in your "commands" folder, create a file called ping.js type the following:
module.exports = function(){
msg.reply("Pong!")
}
Then, in your deploy commands, you type
const ping = require("./commands/ping.js")
clist = {ping}
module.exports = async function(msg){
let tokens = msg.toString().split(" ");
let command = tokens.shift();
if (command.charAt(0) == '!') {
command = command.substring(1);
clist[command](msg, tokens);
}
};
Finally, index.js:
//depencencies,on ready, etc
const commhand = require("./deploy-commands.js")
client.on('message',commhand)
//others
This is assuming it is blank, new file.
It also appears that you are missing function(msg,args) in your files.

1 year ago
Load more