Skip to content
Classcorev0.12.0

WebhookLog

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

Declare the url's environment variable with @WebhookUrl and implement 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.

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

Member visibility

Filter class members by access level.

constructor

Constructs a new instance of the Subscriber class

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

Inherited from:Subscriber

Showing members with Protected visibility and higher.

KeyOfSubscribers

The subscription key or keys that this reporter receives, the same ones as @Subscribe

KeyOfSubscribers extends SubscriptionKey

TCore

The transport's Core

TCore extends CoreBase

core

protected readonly core: TCore

Inherited from:Subscriber

data

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

protected data: SingleKeyData<Keys>

Inherited from:Subscriber

key

protected readonly key: Keys

Inherited from:Subscriber

match()

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.

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

The type that every case must return. Leave it out to get the union of what the cases return.

Throws:

A SeedcordTypeError with MatchCaseMissing when the published key doesn't have a case.

Inherited from:Subscriber

report()

Builds the message for one published event.

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

How many events were dropped since the last card

throttleKey()

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

protected throttleKey(): string | null