public async Task StartAsync() { try { // Creates a new instance of the Discord client. var client = new DiscordSocketClient(); // Initializes all of the required services. var services = await Initialize.StartAsync(client).ConfigureAwait(false); // Gets the credentials required to start the bot. var config = services.GetRequiredService <ConfigModel>(); // Begins Discord login. await client.LoginAsync(TokenType.Bot, config.Credentials.Discord).ConfigureAwait(false); await client.StartAsync().ConfigureAwait(false); await Task.Delay(-1).ConfigureAwait(false); } catch (Exception e) { Console.WriteLine(e); Console.ReadKey(); Environment.Exit(0); } }
public static Task <IServiceProvider> StartAsync(DiscordSocketClient client) { var result = new Initialize(); return(result.InitAsync(client)); }