MeoCord
function in meocord/decorator Since 4.0.0
MeoCord<
const G extends readonly unknown[] = [],
const I extends readonly unknown[] = [],
const F extends readonly unknown[] = [],
>(
options: MeoCordOptions<G, I, F>,
): (target: any, propertyKey?: string | symbol) => voidDeclares the application class: its controllers, services, client options and what applies to every handler.
Put it on one class, the one main.ts passes to MeoCordFactory.create(). What the process needs before this
class is read, the token, build and sharding, belongs in meocord.config.ts instead.
Parameters
| Name | Type | Default | Since | Description |
|---|---|---|---|---|
options | MeoCordOptions<G, I, F> | The app's controllers, client options and the rest; see | ||
options.controllers | ServiceIdentifier[] | 4.1.0 | Controllers to register. | |
options.clientOptions | ClientOptions | 4.1.0 | Options for the discord.js | |
options.activities? | ActivityOptions[] | 4.1.0 | Activities the bot rotates through, in order: the first is shown once the bot is ready, and the next every 10 seconds, starting again after the last. Without them MeoCord leaves the bot's presence as the app sets it. | |
options.services? | ServiceIdentifier[] | 4.1.0 | Services to register that no controller depends on. | |
options.providers? | Provider[] | 4.1.0 | Values classes inject by token with | |
options.guards? | {
[K in keyof G]: CheckedEntry<
G[K],
new (...args: any[]) => GuardInterface
>
} | 4.1.0 | Guards run before every dispatched handler, ahead of the controller's and the method's own guards: guard classes,
or | |
options.interceptors? | {
[K in keyof I]: CheckedEntry<
I[K],
new (
...args: any[]
) => InterceptorInterface
>
} | 4.1.0 | Interceptors run around every dispatched handler except autocomplete, outside the controller's and the method's own. A controller method called directly runs none. | |
options.filters? | {
[K in keyof F]: CheckedEntry<
F[K],
new (
...args: any[]
) => ExceptionFilter<any>
>
} | 4.1.0 | Exception filters tried after the method's and the controller's, and for errors outside any handler, such as
| |
options.i18n? | Translator<any> | 4.1.0 | The translator | |
options.cooldownStore? | new (...args: any[]) => CooldownStore | 4.1.0 | Where | |
options.cooldownStoreFailure? | CooldownStoreFailure | 'deny' | 4.1.0 | What a call with a cooldown gets when the store throws, rejects or does not answer in time: |
options.cooldownStoreTimeoutMs? | number | 1000 | 4.1.0 | How long a call waits for the cooldown store before it counts as a failure, in milliseconds, at most |
options.presenter? | new (...args: any[]) => ResponsePresenter | 4.1.0 | The | |
options.messages? | MessageCommandOptions | 4.1.0 | How message commands start and match across the app: the | |
options.observers? | (new (...args: any[]) => DispatchObserver)[] | 4.1.0 |
| |
options.warnUnanswered? | boolean | on in development (`NODE_ENV` is `development`, as under `meocord start --dev`), off otherwise | 4.1.0 | Warns, once per handler, when a handler, or an interceptor that returns without running it, finishes without answering its interaction, or defers it and never follows up, which leaves the user waiting. |
options.theme? | RootTheme | 4.1.0 | The app's theme: the roles it changes from MeoCord's defaults, and every role the app adds. It applies to every
handler, beneath each | |
options.themeFor? | | ThemeResolvers
| (new (...args: any[]) => ThemeResolver) | 4.1.0 | Themes by where a call comes from: | |
options.themeCache? | {
ttlSeconds?: number
maxGuilds?: number
maxUsers?: number
} | 4.1.0 | How long | |
options.themeForTimeoutMs? | number | 1000 | 4.1.0 | How long a call waits for a |
Returns
Returns a property decorator.
(target: any, propertyKey?: string | symbol) => voidExamples
@Controller()
class PingController {
@Command('ping', CommandType.SLASH)
async ping(interaction: ChatInputCommandInteraction) {
await respond(interaction).send('Pong!')
}
}
@MeoCord({ controllers: [PingController], clientOptions: { intents: [GatewayIntentBits.Guilds] } })
class App {}