34 lines
850 B
C#
34 lines
850 B
C#
using Discord;
|
|
using Discord.WebSocket;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
namespace GodReplacementProduct;
|
|
|
|
public sealed class GodReplacementBot : IHostedService
|
|
{
|
|
private readonly IConfiguration _config;
|
|
private readonly DiscordSocketClient _client;
|
|
|
|
public GodReplacementBot(
|
|
IConfiguration config,
|
|
DiscordSocketClient client
|
|
)
|
|
{
|
|
_config = config;
|
|
_client = client;
|
|
}
|
|
|
|
public async Task StartAsync(CancellationToken cancellationToken)
|
|
{
|
|
var token = _config.GetValue<string>("GodReplacementProject:DiscordToken");
|
|
await _client.LoginAsync(TokenType.Bot, token);
|
|
await _client.StartAsync();
|
|
}
|
|
|
|
public async Task StopAsync(CancellationToken cancellationToken)
|
|
{
|
|
await _client.StopAsync();
|
|
}
|
|
}
|