public void LoadOrCreate() { _logger.Log($"Reading the configuration ({Constants.DISCORD_CONFIG_PATH})"); var discordBotConfig = _dataStorage.RestoreObject <DiscordBotConfig>(Constants.DISCORD_CONFIG_PATH); if (discordBotConfig == null) { discordBotConfig = new DiscordBotConfig(); _dataStorage.StoreObject(discordBotConfig, Constants.DISCORD_CONFIG_PATH); } _config = discordBotConfig; }
private Task HandleReady() { try { _ = activityCycler.ChangeActivityAsync(); // Owner _ = client.GetApplicationInfoAsync() .ContinueWith(x => { ApplicationContext.BotOwner = x.Result.Owner; Console.WriteLine($"Owner Id: {ApplicationContext.BotOwner.Id}"); }); switch (Program.FirstArgument) { case "pm": { discordLogger.Log("Bot has started by a process manager."); break; } default: { if (Program.FirstArgument == null) { break; } discordLogger.Log("Something happened: " + Program.FirstArgument); break; } } } catch (Exception e) { client.StopAsync(); client.LogoutAsync(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(e.Message.AddLine() + e.StackTrace); Console.WriteLine("Failed loading context!"); Console.Error.WriteLine($"{DateTime.Now:yyyy-MM-dd hh:mm:ss} Application has failed to start!"); Environment.Exit(0); } _ = RunTests(); return(Task.CompletedTask); }