@discord-factory/basic-commands
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

📦 Basic commands

The Discord Factory framework no longer includes the use of commands via the messageCreate event by default.

The @discord-factory/basic-commands module allows you to restore the use of these commands.

In order to use the module, you need to take the following steps:

npm install @discord-factory/basic-commands
# or
yarn add @discord-factory/basic-commands

Add the module to the plugins in the App/start/Kernel.ts file:

import BasicCommands from '@discord-factory/basic-commands

export default class Kernel {
  public registerAddons () {
    return [
      () => BasicCommands, 👈 // Do not instanciate it
    ]
  }
}

You can generate a command file by using the command below: With NPM

npm run ace make:basic-command MyCommand

With YARN

yarn ace make:basic-command MyCommand

Now you will need to add 2 keys to your environment file :

BASIC_COMMANDS:
  APP_PREFIX: Your prefix
  COMMAND_AUTO_REMOVE: true # or 'false'
"BASIC_COMMANDS": {
  "APP_PREFIX": "Your prefix"
  "COMMAND_AUTO_REMOVE": true // or 'false'
}

Once added, you can now create your orders with this minimal structure

import { Command, BaseCommand } from '@discord-factory/basic-commands'
import { Message } from 'ioc:factory/Discord/Event'

@Command({
  label: 'Foo command',
  description: 'Foo description',
  tag: 'foo'
})
export default class FooCommand extends BaseCommand {
  public async run (message: Message, args: string[]): Promise<void> {
    // Your code here
  }
}

License

MIT License © 2021 Baptiste Parmantier

Readme

Keywords

none

Package Sidebar

Install

npm i @discord-factory/basic-commands

Weekly Downloads

0

Version

1.2.1

License

MIT

Unpacked Size

36.3 kB

Total Files

33

Last publish

Collaborators

  • leadcodedev