Class DiscordHostedService
Simple implementation for DiscordClient to work as a Microsoft.Extensions.Hosting.BackgroundService
Inheritance
System.Object
Microsoft.Extensions.Hosting.BackgroundService
DiscordHostedService
Inherited Members
Microsoft.Extensions.Hosting.BackgroundService.StartAsync(System.Threading.CancellationToken)
Microsoft.Extensions.Hosting.BackgroundService.StopAsync(System.Threading.CancellationToken)
Microsoft.Extensions.Hosting.BackgroundService.Dispose()
Microsoft.Extensions.Hosting.BackgroundService.ExecuteTask
Namespace: DisCatSharp.Hosting
Assembly: DisCatSharp.Hosting.dll
Syntax
public abstract class DiscordHostedService : BaseHostedService, IDisposable, IDiscordHostedService, IHostedService
Constructors
| Improve this Doc View SourceDiscordHostedService(IConfiguration, ILogger<DiscordHostedService>, IServiceProvider, IHostApplicationLifetime, String)
Initializes a new instance of the DiscordHostedService class.
Declaration
protected DiscordHostedService(IConfiguration config, ILogger<DiscordHostedService> logger, IServiceProvider serviceProvider, IHostApplicationLifetime applicationLifetime, string configBotSection = "DisCatSharp")
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.Configuration.IConfiguration | config | IConfiguration provided via Dependency Injection. Aggregate method to access configuration files |
Microsoft.Extensions.Logging.ILogger<DiscordHostedService> | logger | An ILogger to work with, provided via Dependency Injection |
System.IServiceProvider | serviceProvider | ServiceProvider reference which contains all items currently registered for Dependency Injection |
Microsoft.Extensions.Hosting.IHostApplicationLifetime | applicationLifetime | Contains the appropriate methods for disposing / stopping BackgroundServices during runtime |
System.String | configBotSection | The name of the JSON/Config Key which contains the configuration for this Discord Service |
Properties
| Improve this Doc View SourceClient
Reference to connected client
Declaration
public DiscordClient Client { get; protected set; }
Property Value
Type | Description |
---|---|
DiscordClient |
Methods
| Improve this Doc View SourceConfigureAsync()
Declaration
protected override Task ConfigureAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Overrides
| Improve this Doc View SourceConfigureExtensionsAsync()
Declaration
protected override Task ConfigureExtensionsAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Overrides
| Improve this Doc View SourceConnectAsync()
Declaration
protected sealed override async Task ConnectAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Overrides
Implements
Microsoft.Extensions.Hosting.IHostedService