Free advice: Please don't copy-paste then ask for support because you don't understand it.
//index.jsconstSHClient=require('shandler');constDiscord=require('discord.js');constclient=newDiscord.Client();constoptions= { commandsDir:'commands',// commands folder path (required) showLogs:'extra',// "extra"|"normal"|null (default: "extra") wrapper:false,// defaults to false cLogs:true,// logs most of the resolved promises autoDelete:true,// Automatically syncs the global application commands autoRegister:true,// Automatically register commands exclude: ['file'] // Exclude a file from the command directory. Make sure you only put the file name.}consthandler=newSHClient(client, options);
Let's make a command file.
//ping.jsmodule.exports= { name:'ping',// Will default to filename if this is empty description:'Is this unusual?',//Default: "An awesome command..!" options:[],//We will cover this in the next part guilds: [],/*This is for guild specific command registration if this is empty, this command will be registered globally*/asyncrun({interaction, client}){let ping =Date.now()interaction.reply("Pinging..!").then(m => {m.edit('My ping is '+Date.now() - ping +'ms') }) }}
Command Options
You might've thought what all we can do with the options. Well, you can refer here at the Discord Documentation.
for registering a command you can use the .create() method.
constcommands= [ { name:'ping', description:'Is this unusual?', options:[] }, { name:'user', description:'Shows the info of a user', options:[ { name:'user', description:'A user..!', type:6 } ] }]constguilds= [] //for guild specific commands pass an array for guildIDs. If none, will default to global command.client.on('ready', () => {handler.create(commands, guilds);})