You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.
index.jsconstconfig={"commands": {"directory": "/path/to/commands",//path to commands folder"subcategories": "false"//if commands are divided by folders change to "true"},"bot": {"token": "bot_token_here"}}constDiscord=require('discord.js');constclient=newDiscord.Client();constSlash=require('da-slash');constslash=newSlash.Client(client,config);client.once('ready',()=>{//updates Commandsslash.postCommands();})//emitted when a slash command is detectedclient.ws.on('INTERACTION_CREATE',asyncrequest=>{constinteraction=newSlash.Interaction(client,request);//finds the matching slash command and executes itslash.matchCommand(interaction);})client.login(config.bot.token);
Creating Commands
A file for each command. All files should be contained in one folder or if files are separated by folders, all command folders should be under one command folder.
commandOne.jsconstSlash=require('da-slash');module.exports=newSlash.GlobalCommand({name: 'echo',description: 'sends a message',permissions: ["SEND_MESSAGES"],options: [{"name": "content","description": "message the bot will send","type": 3// Type 3 is string}],execute(interaction){// access discord.Client() through interaction.clientconstclient=interaction.client;// access the data related to the slash command emittedconstrequest=interaction.request;// access the arguments passedconstcontent=request.data.options.find(arg=>arg.name==="content").value;// sends message containing the argumentinteraction.sendMessage(content);}})
commandTwo.jsconstSlash=require('da-slash');module.exports=newSlash.GuildCommand({name: 'hello',description: 'sends a hello message',guilds: ["GuildIdHere"],permissions: ["SEND_MESSAGES"],execute(interaction){interaction.sendMessage("hello");}})