Skip to content
GitHub

MeoCordFactory

class in meocord/core Since 4.0.0

class MeoCordFactory

Creates the application from the class @MeoCord decorates, ready to start.

Call it once, in main.ts, and start() what it returns. Tests build a module with MeoCordTestingModule instead, which reads the same decorators without a client or a config file.

Examples

TypeScript
@MeoCord({ controllers: [], clientOptions: { intents: [GatewayIntentBits.Guilds] } })
class App {}

const app = MeoCordFactory.create(App)
await app.start()

Members

constructor

new MeoCordFactory()

create

static create(target: ServiceIdentifier): MeoCordApplication

Creates the application for an app class, reading its token and config from the compiled config beside the bundle, meocord.config.mjs, wherever the bot is started from.

With process sharding it returns the manager that runs one process per shard; otherwise the bot itself.

Parameters

NameTypeDescription
targetServiceIdentifier

The class @MeoCord decorates.

Returns

MeoCordApplication

The application, which start() logs in.

Throws

  • Error when the class has no @MeoCord, when the compiled config is missing beside the bundle or fails to load, naming the file and the reason, with what to do about it, when a provider cannot be bound, such as one for a token MeoCord binds itself, when two handlers take one command, or two builder classes build one, naming both, and for any other mistake it refuses as the app loads, such as two component patterns that match the same customIds. In a built application it is logged first, with where in the source it comes from, so isExplainedError() tells a caller not to log it again; in a shard of process sharding, the manager logs it.

See also