MeoCordApplication
interface in meocord/core and meocord/interface Since 4.1.0
interface MeoCordApplicationThe application MeoCordFactory.create returns: a bot in one process, or the manager of a process per shard.
main.ts starts it and nothing else needs it: which of the two it is follows from meocord.config.ts's
sharding, and both start and register commands the same way.
Examples
@MeoCord({ controllers: [], clientOptions: { intents: [GatewayIntentBits.Guilds] } })
class App {}
const app: MeoCordApplication = MeoCordFactory.create(App)
await app.start()Members
start
start(): Promise<void>Starts the bot: resolves its providers and logs in, or with process sharding, spawns the shards, each of which does so.
A call while one is under way waits for it, and a call once the bot is online does nothing.
Retrying it after a failed login is deprecated; in the next major version (5.0) it rejects. Use
MeoCordFactory.create to make a new app instead. A retry after a provider's factory failed stays supported.
A shard whose start fails exits 1 once the rejection is handled, and its manager restarts it. When the failure is one every shard would meet, MeoCord refusing the app or Discord refusing the login for good (an invalid token, or intents it disallows or does not know), the manager logs why, stops every shard and exits 1 instead.
Returns
Promise<void>A promise that resolves once the bot is logged in, or every shard has been spawned.
Throws
For a bot in one process, the error of a provider's factory that failed, or the login error, such as an invalid token. A start that
stop()ends rejects, and so does a start of an app already stopped.
stop
stop(): Promise<void>Stops the bot: runs the onShutdown hooks under the configured shutdownTimeout and closes the client, or with
process sharding, asks every shard to shut down and waits for it. It ends no process of its own accord, except that
called in a shard, it asks the manager to stop every shard, which then shuts that shard's process down too. A stop
while the bot starts ends that start, a call after the first waits for it, and a stopped app does not start again.
Returns
Promise<void>A promise that resolves once the bot is stopped. It never rejects: a failure to close is logged, and sets
process.exitCode to 1 unless another code is already set.
registerCommands
registerCommands(): Promise<void>Registers the application's commands with Discord, where meocord.config.ts's commands says.
A failure is logged rather than thrown.
Returns
Promise<void>