Code Monkey home page Code Monkey logo

dyno-fun's Introduction

Fun commands for Dyno

Commands should always return a promise.

Subcommands

Compromises

The way subcommands are implemented right now prevent you from having a return value for ?command, instead, we define a default subcommand that will be executed when ?command is run.

Your execute function for the main command must look like this:

public execute() {
	return Promise.resolve();
}

How to add

Subcommands can be added like so: First define the subcommands in the parent command constructor

this.commands = [
  { name: 'list',   desc: 'List the songs in the music queue.',  usage: 'list',   cooldown: 5000, default: true },
  { name: 'remove', desc: 'Remove a song from the music queue.', usage: 'remove', cooldown: 2000 },
];

Note that the list subcommand is marked as the default. So when the parent command is ran without any subcommands, that subcommand will be executed.

Afterwards, the default command handler will look into that array and match a function name with the subcommand name.

So for example, for the list subcommand, we would add a function on the parent command class with the same name as the subcommand:

async list({ message, args }) {
  //insert awesome command code here
}

async remove({ message, args }) {
  //insert awesome command code here
}

The arguments follow the same format as a non-subcommand.

dyno-fun's People

Contributors

anothergenz avatar benolot avatar bjornmorten avatar briantanner avatar coalsephos avatar eleosos avatar germanoeich avatar imcrispyy avatar inatrance avatar khaaz avatar mikakpk avatar salesawy1 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.