public static void Main(string[] args) { Twitchbot t = new Twitchbot(); NetworkScanner.Espipfound += OnEspFound; chatsw = new Stopwatch(); execsw = new Stopwatch(); chatsw.Start(); execsw.Start(); // scan for the the esp and keep scanning untill found. while (!NetworkScanner.espFound && !NetworkScanner.isScanning) { NetworkScanner.Scan(); Thread.Sleep(500); } // sub to the bot message event TwitchClientIrc.ChatMessage += OnTwitchChat; // start the twitch bot t.Start(); }
public async Task MainAsync() { // call ConfigureServices to create the ServiceCollection/Provider for passing around the services using (var services = ConfigureServices()) { // get the client and assign to client // you get the services via GetRequiredService<T> var client = services.GetRequiredService <DiscordSocketClient>(); _client = client; // setup logging and the ready event client.Log += LogAsync; services.GetRequiredService <CommandService>().Log += LogAsync; // this is where we get the Token value from the configuration file, and start the bot await client.LoginAsync(TokenType.Bot, _config["Token"]); await rclient.LoginAsync(TokenType.Bot, _config["Token"]); await client.StartAsync(); Twitchbot twitchbot = new Twitchbot(twitchclient, _config, _client); // sets the bots status indicator to "Do not disturb" if its still on cooldown if (File.Exists("db/lastmessage.37")) { var last37 = Convert.ToDateTime(File.ReadAllText("db/lastmessage.37")); TimeSpan ts = DateTime.UtcNow - last37; if (ts.TotalMinutes < Int32.Parse(_config["Frequency"])) { Cooldown cooldown = new Cooldown(); cooldown.CooldownAsync((int)(int.Parse(_config["Frequency"]) * 1000 * 60 - ts.TotalMilliseconds), _client); } } // we get the CommandHandler class here and call the InitializeAsync method to start things up for the CommandHandler service await services.GetRequiredService <CommandHandler>().InitializeAsync(); await Task.Delay(-1); } }