-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
45 lines (38 loc) · 1.25 KB
/
Program.cs
File metadata and controls
45 lines (38 loc) · 1.25 KB
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
using System;
using System.Globalization;
using System.IO;
using Newtonsoft.Json;
namespace QuaverBot;
public class Program
{
public static void Main(string[] args)
{
if (!File.Exists("config.json"))
{
File.WriteAllText("config.json", JsonConvert.SerializeObject(BotConfig.Default, Formatting.Indented));
Console.WriteLine("Please fill in the config.json file.");
return;
}
BotConfig config = JsonConvert.DeserializeObject<BotConfig>(File.ReadAllText("config.json"));
if (args.Length > 0 && args[0] == "regen")
{
File.WriteAllText("config.json", JsonConvert.SerializeObject(config, Formatting.Indented));
Console.WriteLine("Regenerated config.json.");
return;
}
Logger.LogLevel = config.LogLevel;
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;
restart:
try
{
new QuaverBot(config).MainAsync().GetAwaiter().GetResult();
}
catch
{
// "gotos are illegal": womp womp
// simply uncrash yourself
goto restart;
}
}
}