Coder Social home page Coder Social logo

friendly-octo-umbrella's Introduction

Slash bot template

A bot with a easy way to add slass commands!

GitHub package.json version GitHub code size in bytes GitHub

Add slash commands from json file!

Example

Let's suppose we have this PING command in /options/commands.json:

{
  "PING": {
    "name": "ping",
    "description": "ping! pong!"
  }
}

Having this we just need to use the guild /add command, and you can choose if it will be a guild or global command:

To remove the PING command we just need to use /delete like /add command:

This doesn't change anything in json file!

Usage

First you need a .env file with: TOKEN='your bot token'

To start adding commands for your bot first you need to add the /add command, then we use it to add the /delete command!

To add the /add command put this code inside the READY event in index.js with your guild id, remembering that it will only be used once.

const json = require('./options/commands.json')

client.api.applications(client.user.id)
    .guilds('YOUR GUILD ID')
    .commands.post({data: json['ADD']})

Now you can use the command:

/add guild: DELETE

to add the /delete command like we saw on Example.

Everything command you want to add just edit the /options/commands.json using the following style:

"COMMAND1": {
  "name": "command1",
  "description": "description of 1"
}
"COMMAND2": {
  "name": "command2",
  "description": "description of 2",
  "options": [{
    "name": "option1",
    "description": "description of op1"
  }]
}

So you go to discord and use

/add guild: COMMAND1

or

/add global: COMMAND2

and obviously you need to make the command JavaScript file on /commands/command1.js!

You also can use /add guild: command doesn't matter if is on upper or lower case

License

MIT

friendly-octo-umbrella's People

Contributors

zstrikecode avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.