Skip to content

📦 The Discord Factory framework no longer includes the use of commands via the messageCreate event by default. This module allows you to restore the use of these commands.

License

Notifications You must be signed in to change notification settings

DiscordFactory/message-commands

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📦 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

About

📦 The Discord Factory framework no longer includes the use of commands via the messageCreate event by default. This module allows you to restore the use of these commands.

Resources

License

Stars

Watchers

Forks