-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
50 lines (44 loc) · 1.66 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using CoinGecko.Clients;
using CoinGecko.Interfaces;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using System.IO;
using Discord.Rest;
using Discord.WebSocket;
using System.Globalization;
using System.Threading;
namespace DiscordCryptoSidebarBot // Note: actual namespace depends on the project name.
{
public class Program
{
static async Task Main(string[] args)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
using IHost host = CreateHostBuilder(args).Build();
await host.RunAsync();
}
static IHostBuilder CreateHostBuilder(string[] args)
{
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile(path: "config.json", optional: false, reloadOnChange: true)
.AddCommandLine(args)
.Build();
return Host.CreateDefaultBuilder(args).ConfigureServices((context, services) =>
{
services.Configure<BotSettings>(configuration)
.AddSingleton<DiscordRestClient>()
.AddSingleton<DiscordSocketClient>()
.AddSingleton<ICoinGeckoClient>(CoinGeckoClient.Instance)
.AddHostedService<TimedBackgroundPriceService>()
.AddHttpClient<EthGasService>();
services.AddHttpClient<CustomApiService>();
});
}
}
}