DiscordBuddy - Common
This package includes some common modules and argument types for DiscordBuddy. These argument types will range from a normal string type to a discord object.
Currently DiscordBuddy requires you to register CoreModule
in your bootstrap module, however if you'd like to have some more arguments available you can import the CommonModule
from this package. Below are some examples on how to import the module and how to use the argument types in your commands.
// MainModule.ts
import { Module } from '@discordbuddy/core';
import { CommonModule } from '@discordbuddy/common';
import { SomeCommand } from './commands/SomeCommand';
@Module({
commands: [SomeCommand],
imports: [CommonModule]
})
export class MainModule {}
// commands/SomeCommand.ts
import { Command, Message } from '@discordbuddy/core';
import { StringType } from '@discordbuddy/common';
@Command({
name: 'some',
description: 'A command with a string argument type',
args: [{
key: 'aString',
type: StringType
}]
})
export class SomeCommand {
public async run(message: Message, args) {
message.reply(`Got ${args.length} argument(s)\naString: ${args.aString}`);
}
}