# WebhookLog

`class` in `core` · v0.12.0

<https://seedcord.org/docs/packages/core/0.12.0/classes/webhook-log>

Base class for subscribers that deliver their event to a Discord webhook.

Declare the url's environment variable with `@WebhookUrl` and implement [`report`](/docs/packages/core/0.12.0/classes/webhook-log#report). The base
resolves the url, validates it, reuses one sender per url, and sends. Registration skips a reporter
whose variable is unset and warns at boot.

```ts
abstract class WebhookLog<
    KeyOfSubscribers extends SubscriptionKey,
    TCore extends CoreBase
> extends Subscriber<KeyOfSubscribers, TCore>
```

## Constructors

### constructor

```ts
Subscriber(payload: AllSubscriptions[Keys], core: TCore, key: Keys)
```

Constructs a new instance of the `Subscriber` class

## Properties

### core

```ts
protected readonly core: TCore
```

### data

```ts
protected data: SingleKeyData<Keys>
```

The published payload. It's `never` on a subscriber for several keys, where `this.match` reads it.

### key

```ts
protected readonly key: Keys
```

### logger

```ts
protected readonly logger: Logger
```

## Methods

### execute

```ts
public async execute(): Promise<void>
```

### match

```ts
protected async match<Ret, Cases>(
    cases: OnlyCases<Cases, SubscriberMatchCases<Keys, Ret>>
): Promise<MatchResult<Ret, Cases>>
```

Run the case for the published key. Use this only when the subscriber is registered for several
keys. On a single-key subscriber, read `this.data` directly.

Provide one case per registered key. Each case receives that key's own payload. A missing key or an unknown
key is a compile error.

### report

```ts
public abstract report(
    suppressed: number
): WebhookReport | Promise<WebhookReport>
```

Builds the message for one published event.

### throttleKey

```ts
protected throttleKey(): string | null
```

Events sharing this key collapse into one card per minute. Return `null` to send every event.
