# Seedcord

`class` in `http` · v0.7.0

<https://docs.seedcord.org/packages/http/0.7.0/classes/seedcord>

The HTTP-interactions bot host, a long-running node server around the engine.

Discovers handlers from `config.bot.interactions.path`, verifies and dispatches interactions on `start()`, and runs coordinated shutdown with an in-flight drain. The edge deploy path calls `createSeedcord` from a generated entry.

```ts
class Seedcord<Cfg extends HttpConfig = HttpConfig>
    extends Pluggable<"http", RuntimeOfConfig<Cfg>>
    implements Core, SeedcordInstance
```

## Constructors

### constructor

```ts
Seedcord(config: Cfg)
```

Constructs a new instance of the `Seedcord` class

## Properties

### applicationId

```ts
public get applicationId(): string
```

The bot's Discord application id. Throws if you read it before the Configuration phase.

### bus

```ts
public readonly bus: Bus
```

### config

```ts
public readonly config: Cfg
```

### isInitialized

```ts
protected isInitialized: boolean
```

### plugins

```ts
protected readonly plugins: PluginLike[]
```

### port

```ts
public get port(): number | undefined
```

The bound server port, populated once `start()` is listening.

### rateLimiter

```ts
public readonly rateLimiter: IRateLimiter
```

### rest

```ts
public readonly rest: REST
```

Workerd-compatible Discord REST client. `start()` sets the token.

### shutdown

```ts
readonly shutdown: Pick<CoordinatedShutdown, 'addTask'>
```

Add a task that runs while the bot shuts down.

### startFailed

```ts
protected startFailed: boolean
```

### startup

```ts
readonly startup: Pick<CoordinatedStartup, 'addTask'>
```

Add a task that runs while the bot starts.

### username

```ts
public get username(): string | undefined
```

The bot's discord username, populated by the ready fetch.

## Methods

### attach

```ts
attach<Key, Ctor>(
    this: this,
    key: ChannelKeyAssert<Key>,
    Plugin: Ctor &
        TransportAssert<InstanceType<Ctor>, BotT> &
        RuntimeAssert<InstanceType<Ctor>, BotRt> &
        CoreParamAssert<Ctor>,
    args: PluginArgs<Ctor>
): this & Record<Key, InstanceType<Ctor>>
```

Attaches a plugin under `key`. Read the instance back as `core[key]`. `seedcord codegen` writes the `Core` augmentation that types it there.

Startup runs each plugin's `init()` in attach order within its phase.

Attaching a plugin whose `transport` or `runtime` differs from this host fails to compile. Your constructor takes `CoreBase` as its first parameter (you don't need to pass it though). A narrower one fails to compile here.

### reset

```ts
protected static reset(host?: object): boolean
```

### start

```ts
public async start(): Promise<this>
```

Starts the host and runs the startup tasks.
