SLCommands
  • SLCommands Documentation
  • Easy Setup & Options Object
  • SLCommands Class Methods
  • Commands & Contexts
    • Ping command example
    • Command methods
    • Subcommands
  • Events & Features
    • How does features and events work?
    • SLCommands Events
  • Utilities
    • SLCommands Embeds
    • Custom Messages
  • Hope you liked!
Powered by GitBook
On this page
  1. Commands & Contexts

Ping command example

PreviousSLCommands Class MethodsNextCommand methods

Last updated 2 years ago

Welcome to Commands & Contexts section!

First you must setup you SLCommands:

Then create a "commands" folder where you can create a "ping.js" or "ping.ts" file.

Do not forget: onExecute or addSubCommand must be the last functions, so the command is properly registered.

ping.js
const { ChatInputCommand } = require('sl-commands')

new ChatInputCommand()
  // The command name (required)
  .setName('ping')
  // The command description (required)
  .setDescription('Shows my ping')
  // Only register for the testing servers
  .setTestOnly(true)
  // Executed whenever the command is used
  .onExecute(({ client, interaction }) => {
    // Replying the slash command interaction
    interaction.reply(`API's ping is ${client.ws.ping}`)
  })
ping.ts
import { ChatInputCommand } from 'sl-commands'

new ChatInputCommand()
  // The command name (required)
  .setName('ping')
  // The command description (required)
  .setDescription('Shows my ping')
  // Only register for the testing servers
  .setTestOnly(true)
  // Executed whenever the command is used
  .onExecute(({ client, interaction }) => {
    // Replying the slash command interaction
    interaction.reply(`API's ping is ${client.ws.ping}`)
  })
Easy Setup & Options Object