# Pluggable

`class` in `core/node` · v0.7.0

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

Base class for a plugin host, a transport `Seedcord` class.

You attach plugins while configuring the bot. Within one startup phase, their `init()` calls run one after another in attach order.

```ts
abstract class Pluggable<
    BotT extends Transport,
    BotRt extends Runtime
> implements CoreBase
```

## Constructors

### constructor

```ts
Pluggable(shutdown: CoordinatedShutdown, startup: CoordinatedStartup)
```

Constructs a new instance of the `Pluggable` class

## Properties

### applicationId

```ts
public readonly abstract applicationId: string
```

### bus

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

### config

```ts
public readonly abstract config: Config
```

### isInitialized

```ts
protected isInitialized: boolean
```

### plugins

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

### rateLimiter

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

### rest

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

### shutdown

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

Add a task that runs while the bot shuts down.

### startFailed

```ts
protected startFailed: boolean
```

### startup

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

Add a task that runs while the bot starts.

## Methods

### attach

```ts
public 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.
