-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
35 lines (31 loc) · 1.24 KB
/
Program.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
// <copyright file="Program.cs" company="https://qsharp.community/">
// Copyright (c) Chris Granade. Licensed under the MIT License.
// </copyright>
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
public class Program
{
public static async Task Main(string[] args)
{
// Load environment variables from any .env files on the directory
// path leading up from here. This allows us to set secrets as
// environment variables on the server, but still locally test by
// using .env files.
DotNetEnv.Env.TraversePath().Load();
// Build the web host, including all Discord bot services as well.
var host = CreateHostBuilder(args).Build();
// Start the Discord bot in the background.
host.Services.ConnectDiscordToLogging();
await host.Services.GetRequiredService<Bot>().Start();
// Finally, run the web host.
host.Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}