public async Task MainAsync(string[] cmdArgs) { // List of items to clean up when the bot exits _disposables = new List <IDisposable>(); ArgParse args = new ArgParse(); args.AddDefs(_ARG_DEFS); args.Parse(cmdArgs); bool encryptOnlyMode = args.GetFlag("encrypt-only"); string givenPassword = args.GetValue("password"); string givenToken = args.GetValue("token"); string token = String.Empty; if (encryptOnlyMode) { Console.WriteLine("Encrypt-only mode."); if (givenToken != String.Empty) { if (givenPassword != String.Empty) { Console.WriteLine("Using password."); } else { Console.WriteLine("Not using password."); } StoreToken(givenToken, givenPassword); Console.WriteLine("Token stored successfully."); } else { Console.WriteLine("Encrypt-only mode must be used with a token. Run with option --token <string>."); } return; } else if (givenToken != String.Empty) { Console.WriteLine("Storing token."); if (givenPassword != String.Empty) { Console.WriteLine("Using password."); } else { Console.WriteLine("Not using password."); } StoreToken(givenToken, givenPassword); token = givenToken; } else { // Handle user-mode BotToken.ReadToken(); switch (BotToken.GetTokenState()) { case BotTokenState.Unchecked: case BotTokenState.Valid: Console.WriteLine("Loading Discord bot token."); token = HandleTokenDecrypt(); break; case BotTokenState.Missing: case BotTokenState.Outdated: case BotTokenState.Corrupted: token = PromptAndStoreToken(); break; } } if (token == String.Empty) { Console.WriteLine("Stopping. (Press any key to end)"); Console.ReadKey(); return; } var config = new DiscordSocketConfig(); config.AlwaysDownloadUsers = true; var client = new DiscordSocketClient(config); client.Log += Log; client.Ready += Ready; client.MessageReceived += MessageReceived; _adminList = new AdminList(client); _disposables.Add(_adminList); Server watsonLocal = new Server("localhost", 9000, false, DefaultRoute, false); watsonLocal.AddStaticRoute("get", "/hello/", HelloRoute); watsonLocal.AddStaticRoute("get", "/queue/", QueueRoute); _msgQueue = new Queue(); await client.LoginAsync(TokenType.Bot, token); await client.StartAsync(); await Task.Delay(-1); }