class Seedcord
extends ServerHost<"gateway">
implements SeedcordInstanceMember visibility
Filter class members by access level.
Seedcord(config: GatewayConfig)configBot configuration including paths and Discord client options
Throws:
A SeedcordError when another Seedcord exists in this process and has not shut down.
Throws:
A SeedcordError when the running Node or Bun is older than the range in engines.
public get applicationId(): stringbus
public readonly config: GatewayConfigkv
port
The port the bot's web server listens on. undefined until start() opens it, and when the bot doesn't open one.
Inherited from:ServerHost
rateLimiter
public readonly rest: RESTshutdown
Add a task that runs while the bot shuts down.
readonly shutdown: ShutdownTasksInherited from:ServerHost
startup
Add a task that runs while the bot starts.
readonly startup: StartupTasksInherited from:ServerHost
url
The address people reach your bot at, from server.url in your config. You only need to set
server.url if a plugin or your own code reads this.
get url(): URLThrows:
A SeedcordError when you read it and you haven't set server.url unless seedcord dev gave the bot an address.
Throws:
A SeedcordTypeError when you read it and server.url isn't an http or https address.
Inherited from:ServerHost
[Symbol.asyncDispose]()
Runs the coordinated shutdown without calling process.exit. A new Seedcord can be
constructed afterwards. await using calls this when its scope ends.
// the bot shuts down when this block ends
await using bot = await new Seedcord(config).start();
console.log(await bot.rest.get(Routes.user('@me')));Inherited from:ServerHost
attach()
Attaches a plugin under key. Read the instance back as core[key]. seedcord codegen
writes the Core augmentation that types it there.
Put one dot in the key to nest the plugin under a group. 'services.users' reads back as
core.services.users. Each name holds one plugin or one group.
Startup runs each plugin's init() in attach order within its phase. A node bot starts in
start(). An edge bot starts on its first request.
Attaching a plugin whose transport or runtime differs from this host fails to compile.
Take CoreBase as your constructor's first parameter. attach() passes it, so you don't.
A narrower one fails to compile here.
attach<Key, Ctor>(
this: this,
key: AttachKeyAssert<Key, this>,
Plugin: AttachableCtor<Ctor, BotT, BotRt>,
args: PluginArgs<Ctor>
): this & Attached<Key, InstanceType<Ctor>>keyAlso the channel that the plugin logs on, dots included.
argsWhatever your constructor takes after the host.
Throws:
A SeedcordError when you attach after the bot has started.
Throws:
A SeedcordTypeError when key is taken, reserved, or malformed.
Throws:
A SeedcordTypeError when the plugin extends Plugin from another copy of @seedcord/core.
Throws:
A SeedcordTypeError when another plugin uses a key from this plugin's dispatchMembers.
Throws:
A SeedcordTypeError when seedcord already uses a key from this plugin's dispatchMembers.
Throws:
A SeedcordTypeError when the plugin's transport or runtime differs from this host and the types were bypassed.
seedcord.attach('db', Mongoose, { uri: 'mongodb://...', name: 'seedcord', dir: ... });Inherited from:PluginHost
fetch()
Answers one web request: the health path, then each plugin's fetch in attach order. When
every plugin passes, an http bot's interactions engine gets a POST, and anything else gets a
404. Mount it in your own server when you set server: { port: false }, and send it
every path so plugin routes reach the bot.
Rejects with CoreFetchBeforeStart until start() is called. Until every plugin's ready()
finishes, the health path answers 503. Any other request waits until the Ready phase begins.
Answers 503 once shutdown begins or start() fails.
// Hono passes the untouched request through c.req.raw
const seedcord = new Seedcord({ ...config, server: { port: false } });
await seedcord.start();
const app = new Hono();
app.all('*', (c) => seedcord.fetch(c.req.raw));Inherited from:ServerHost
public async start(): Promise<this>