public void StopButton_ClickCommand() { if (_miunie.MiunieDiscord.ConnectionState is ConnectionState.CONNECTED) { _miunie.Stop(); } }
public Task ToggleBotConnection() { if (_miunie.MiunieDiscord.ConnectionState == ConnectionState.DISCONNECTED) { _ = _miunie.StartAsync(); } else if (_miunie.MiunieDiscord.ConnectionState == ConnectionState.CONNECTED) { _miunie.Stop(); } return(Task.CompletedTask); }
private static async Task HandleInput() { while (true) { DisplayMenu(); DrawMiunieState(); Console.Write(ConsoleStrings.PLEASE_ENTER_MENU_NUMBER); var success = int.TryParse(Console.ReadLine(), out var choice); if (!success) { Console.WriteLine(ConsoleStrings.ERROR_CHOICE_NOT_A_NUMBER); } switch (choice) { case 1: { string token; do { Console.Clear(); Console.Write(ConsoleStrings.ENTER_TOKEN); token = Console.ReadLine(); Console.Clear(); Console.WriteLine(ConsoleStrings.IS_TOKEN_CORRECT, token); Console.WriteLine(ConsoleStrings.YES_NO_PROMPT); }while (Console.ReadKey().Key != ConsoleKey.Y); _editor.WriteSetting("DiscordToken", token); _editor.Save(); _miunie.BotConfiguration.DiscordToken = token; break; } case 2: { if (_miunie.MiunieDiscord.ConnectionState == ConnectionState.CONNECTED) { _miunie.Stop(); AnyKeyToContinue(); } else if (_miunie.MiunieDiscord.ConnectionState == ConnectionState.DISCONNECTED) { _miunie.BotConfiguration.DiscordToken = _configManager.GetValueFor("DiscordToken"); _miunie.BotConfiguration.CommandsEnabled = true; _ = _miunie.StartAsync(); AnyKeyToContinue(); } break; } case 3: { Environment.Exit(0); break; } case 4: { if (_miunie.MiunieDiscord.ConnectionState == ConnectionState.CONNECTED) { await _serverMenu.ServerMenuAsync(); } else { Console.WriteLine(ConsoleStrings.BOT_IS_NOT_RUNNING); AnyKeyToContinue(); } break; } default: { Console.WriteLine(ConsoleStrings.UNKNOWN_OPTION_SELECTED); AnyKeyToContinue(); break; } } } }