1
0
DiscordMediaRichPresence/DiscordMediaRP/Program.cs

41 lines
1.3 KiB
C#
Raw Normal View History

2024-02-22 02:46:19 +01:00
// See https://aka.ms/new-console-template for more information
using DiscordMediaRP;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
2024-02-22 02:46:19 +01:00
Config? c = null;
if (File.Exists("config.json"))
c = JsonConvert.DeserializeObject<Config>(File.ReadAllText("config.json"));
2024-02-22 03:24:18 +01:00
int discordKeyIndex = Array.IndexOf(args, "-d");
2024-02-22 03:57:19 +01:00
if (discordKeyIndex > -1)
if (discordKeyIndex + 1 < args.Length)
if (c is null)
c = new Config()
{
DiscordKey = args[discordKeyIndex + 1]
};
else
c = c.Value.WithDiscordKey(args[discordKeyIndex + 1]);
2024-02-22 03:24:18 +01:00
else
throw new IndexOutOfRangeException("No Discord ApplicationKey provided");
else if(c is null)
throw new ArgumentNullException(nameof(Config.DiscordKey));
int loglevelIndex = Array.IndexOf(args, "-l");
if(loglevelIndex > -1)
if (loglevelIndex + 1 < args.Length)
c = c.Value.WithLogLevel(Enum.Parse<LogLevel>(args[loglevelIndex + 1]));
else
throw new IndexOutOfRangeException(nameof(loglevelIndex));
2024-02-22 03:24:18 +01:00
int imageKeyIndex = Array.IndexOf(args, "-i");
if(imageKeyIndex > -1)
if (imageKeyIndex + 1 < args.Length)
c = c.Value.WithLargeImageKey(args[imageKeyIndex + 1]);
2024-02-22 03:24:18 +01:00
else
throw new IndexOutOfRangeException(nameof(imageKeyIndex));
DisMediaRP _ = new (c.Value);