1.0.0 • Published 3 years ago

@discord-factory/message-commands v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

📦 Message commands

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

The @discord-factory/message-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/message-commands
# or
yarn add @discord-factory/message-commands

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

import MessageCommands from '@discord-factory/message-commands'

export default class Kernel {
  public registerAddons () {
    return [MessageCommands] 👈 // Do not instanciate it
  }
}

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

npm run factory make:message-command MyCommand

With YARN

yarn factory make:message-command MyCommand

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

MESSAGE_COMMANDS:
  APP_PREFIX: Your prefix
  COMMAND_AUTO_REMOVE: true # or 'false'
"MESSAGE_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