Add a scaffold for a command
This commit is contained in:
33
GodReplacementProduct/GodReplacementBot.cs
Normal file
33
GodReplacementProduct/GodReplacementBot.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user