# Seedcord

`class` in `gateway` · v0.5.1

<https://docs.seedcord.org/packages/gateway/0.5.1/classes/seedcord>

The gateway bot host. Opens a discord.js gateway session, discovers handlers, and runs coordinated startup and shutdown. Attach plugins with `attach()`.

```ts
class Seedcord
    extends Pluggable<"gateway", "server">
    implements Core, SeedcordInstance
```

## Constructors

### constructor

```ts
Seedcord(config: GatewayConfig)
```

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 login.

### bot

```ts
public readonly bot: Bot
```

### bus

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

### config

```ts
public readonly config: GatewayConfig
```

### isInitialized

```ts
protected isInitialized: boolean
```

### plugins

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

### rateLimiter

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

### rest

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

The discord.js client's REST client. Its token is set during the Login phase.

### 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 after login.

## 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 bot and runs all initialization tasks
