Table of Contents
API reference

Class BaseHostedService

Namespace
DisCatSharp.Hosting
Assembly
DisCatSharp.Hosting.dll

Contains the common logic between having a DiscordClient or DiscordShardedClient as a Hosted Service

public abstract class BaseHostedService : BackgroundService, IHostedService, IDisposable
Inheritance
BaseHostedService
Implements
Derived
Inherited Members

Fields

ApplicationLifetime
BotSection
Configuration
Logger
ServiceProvider

Methods

ConfigureAsync()

Configure / Initialize the DiscordClient or DiscordShardedClient

ConfigureExtensionsAsync()

Configure the extensions for your DiscordShardedClient or DiscordClient

ConnectAsync()

Connect your client(s) to Discord

ExecuteAsync(CancellationToken)

This method is called when the IHostedService starts. The implementation should return a task that represents the lifetime of the long running operation(s) being performed.

InitializeExtensions(DiscordClient)

Dynamically load extensions by using Configuration and ServiceProvider

OnInitializationError(Exception)

When the bot(s) fail to start, this method will be invoked. (Default behavior is to shutdown)

PostConnectAsync()

Runs immediately after ConnectAsync().

PreConnectAsync()

Runs just prior to ConnectAsync().