-
Notifications
You must be signed in to change notification settings - Fork 0
/
Constants.cs
66 lines (56 loc) · 2.37 KB
/
Constants.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System.Collections;
using EconomyBot.Logging;
using Newtonsoft.Json.Linq;
using Spectre.Console;
using SpotifyAPI.Web;
namespace EconomyBot;
public static class Constants {
private static readonly Logger logger = Logger.getClassLogger("Constants");
public static ulong szerepjatek = 886722112310632499;
public static ulong server = 828296966324224020;
public static string? token;
public static string? redditappid;
public static string? redditrefreshtoken;
public static string? redditappsecret;
public static string? apikey;
public static string? apikey_huggingface;
public static string? spotifytoken;
public static string? spotifytoken2;
public static string? detectlanguagetoken;
public static void init() {
JObject json;
try {
json = JObject.Parse(File.ReadAllText("config.json"));
}
catch (FileNotFoundException e) {
logger.error("The bot doesn't work without a config.json file, please create one.");
return;
}
token = json["token"]?.Value<string>();
if (token is null) {
logger.warn("Discord API token not found.");
}
(apikey, apikey_huggingface) = (json["google"]?.Value<string>(), json["huggingface"]?.Value<string>());
if (apikey is null || apikey_huggingface is null) {
logger.warn("Google/Perspective tokens not found.");
}
(spotifytoken, spotifytoken2) = (json["spotify1"]?.Value<string>(), json["spotify2"]?.Value<string>());
if (spotifytoken is null || spotifytoken2 is null) {
logger.warn("Spotify token not found.");
}
// totally not a gross hack to do some deconstructing
(redditappid, redditrefreshtoken, redditappsecret) =
(json["reddit1"]?.Value<string>(), json["reddit2"]?.Value<string>(), json["reddit3"]?.Value<string>());
if (redditappid is null || redditrefreshtoken is null || redditappsecret is null) {
logger.warn("Reddit tokens not found.");
}
detectlanguagetoken = json["detecttoken"].Value<string>();
if (detectlanguagetoken is null) {
logger.warn("Language detection API token not found.");
}
logger.info("Constants setup!");
}
public static IToken getSpotifyToken() {
throw new NotImplementedException();
}
}