Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.
xlyr.on edited this page Jan 23, 2021 · 17 revisions

Client

constructor

new Slash.Client(discordClient, config);
Parameter Type Description required
client Discord Client a discord client true
config object bot settings true
refer to usage below for config object structure

properties

.client - discord client
.config - bot settings
type: object

methods

.commands() - Gets all commands
returns Promise <Map<Command>>
.findCommand(name) - Get a command by name
returns Promise <Command>
Parameter Type Description required
name string name of command true
.matchCommand(interaction) - Runs through all commands and executes match
returns Promise <...command, securityCheck>
Parameter Type Description required
interaction Interaction slash interaction object true
.postCommands() - Posts/updates all commands
returns void

usage

index.js

const config = {
"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"
  }    
}

const Discord = require('discord.js');
const client = new Discord.Client();
const Slash = require('da-slash');
const slash = new Slash.Client(client, config);

client.once('ready', () => {
  //updates Commands
  slash.postCommands();
})

//emitted when a slash command is detected
client.ws.on('INTERACTION_CREATE', async request => {
  const interaction = new Slash.Interaction(client, request);
  //finds the matching slash command and executes it
  slash.matchCommand(interaction); 
})

client.login(config.bot.token);