JSPM

gcommands

1.0.48
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12
  • Score
    100M100P100Q70405F
  • License MIT

Open-source slah command handler

Package Exports

  • gcommands

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gcommands) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

G Commands


Installation

npm install gcommands

DEV build

npm install github:Garlic-Team/GCommands#dev

Support

How to use?
index.js

const { GCommands } = require("gcommands");
const Discord = require("discord.js");

const client = new Discord.Client();

client.on("ready", () => {
    new GCommands(client, {
        cmdDir: "commands",
        errorMessage: "Error :(",
        slash: {
           slash: 'both', //true = slash only, false = only normal, both = slash and normal
           prefix: '.' 
        },
        cooldown: {
            message: "Please wait {cooldown} more second(s) before reusing the \`{cmdname}\` command.",
            default: 3
        }
    })
})

client.login("token")

Example Commands (put to cmdDir)

ping.js

module.exports = {
    name: "ping",
    description: "Check bot ping",
    cooldown: 3,
    run: async(client, slash, message) => {
        if(message) {
            return message.channel.send("My ping is `" + Math.round(client.ws.ping) + "ms`")
        }

        client.api.interactions(slash.id, slash.token).callback.post({
            data: {
                type: 4,
                data: {
                    content: "My ping is " + Math.round(client.ws.ping) + "ms"
                }
            }
        })
    }
};

test.js

module.exports = {
    name: "test",
    description: "Test",
    expectedArgs: "<name>",
    minArgs: 1,
    cooldown: 5,
    guildOnly: "id",
    ownerOnly: "id",
    run: async(client, slash, message, args) => {
        if(message) {
            if(args[0]) {
                return message.channel.send("My ping is `" + Math.round(client.ws.ping) + "ms`")
            } else {
                return message.channel.send("Need args")
            }
        }

        client.api.interactions(slash.id, slash.token).callback.post({
            data: {
                type: 4,
                data: {
                    content: "My ping is `" + Math.round(client.ws.ping) + "ms`"
                }
            }
        })
    }
};