2024-02-22 02:46:19 +01:00
|
|
|
|
// See https://aka.ms/new-console-template for more information
|
|
|
|
|
|
|
|
|
|
using DiscordMediaRP;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
2024-02-22 17:25:13 +01:00
|
|
|
|
using Newtonsoft.Json;
|
2024-02-22 02:46:19 +01:00
|
|
|
|
|
2024-02-22 17:25:13 +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)
|
2024-02-22 17:25:13 +01:00
|
|
|
|
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");
|
2024-02-22 17:25:13 +01:00
|
|
|
|
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)
|
2024-02-22 17:25:13 +01:00
|
|
|
|
c = c.Value.WithLargeImageKey(args[imageKeyIndex + 1]);
|
2024-02-22 03:24:18 +01:00
|
|
|
|
else
|
|
|
|
|
throw new IndexOutOfRangeException(nameof(imageKeyIndex));
|
|
|
|
|
|
2024-02-22 17:25:13 +01:00
|
|
|
|
DisMediaRP _ = new (c.Value);
|