-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bot.cs
37 lines (30 loc) · 920 Bytes
/
Bot.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// <copyright file="Bot.cs" company="https://qsharp.community/">
// Copyright (c) Chris Granade. Licensed under the MIT License.
// </copyright>
using System;
using System.Threading.Tasks;
using Discord;
using Discord.Commands;
using Discord.WebSocket;
using Microsoft.Extensions.DependencyInjection;
public class Bot
{
private DiscordSocketClient client;
private CommandHandler commands;
public Bot(DiscordSocketClient client, CommandHandler commands)
{
this.commands = commands;
this.client = client;
}
public async Task Start()
{
var token = System.Environment.GetEnvironmentVariable("TOKEN");
if (token == null)
{
throw new Exception("No Discord API token provided; quitting.");
}
await client.LoginAsync(TokenType.Bot, token);
await client.StartAsync();
await commands.InstallCommands();
}
}