public async Task FindNewSessionAsync()
        {
            IUserMessage response;
            EmbedBuilder initialBuilder;


            initialBuilder = EmbedHelper.GetDefaultEmbed(Context);
            initialBuilder.AddField(":mag: Finding new session", "Please wait...");

            response = await ReplyAsync("", embed : initialBuilder.Build());

            try {
                EmbedBuilder    embed;
                IntPtr          windowHandle;
                ProcessProvider provider;


                embed    = EmbedHelper.GetDefaultEmbed(Context);
                provider = new ProcessProvider();

                embed.AddField(":robot: Stopping bot process", "Please wait...");

                _screenshotProvider.Stop();

                embed.AddField(":white_check_mark: Success", "The bot process has been stopped.");
                embed.AddField(":mag: Finding new session", "Please wait...");

                await response.ModifyAsync(msg => { msg.Embed = embed.Build(); msg.Content = ""; });

                windowHandle = provider.GetGrandTheftAutoProcessPointer();

                User32.GetWindowThreadProcessId(windowHandle, out uint processID);

                if (processID != 0)
                {
                    Process process;


                    process = Process.GetProcessById((int)processID);

                    process.Suspend();
                    Thread.Sleep(8000);
                    process.Resume();
                }


                embed.AddField(":white_check_mark: Success", "A new session has been found.");
                embed.AddField(":robot: Starting bot script", "Please wait");

                await response.ModifyAsync(msg => { msg.Embed = embed.Build(); msg.Content = ""; });

                _screenshotProvider.Start();

                embed.AddField(":white_check_mark: Success", "Bot script started ");

                await response.ModifyAsync(msg => { msg.Embed = embed.Build(); msg.Content = ""; });
            } catch (Exception e) {
                await response.ModifyAsync(msg => msg = ErrorHandler.GetDefaultErrorMessageEmbed(e, msg, Context.Message));
            }
        }
示例#2
0
        public async Task ShutdownAsync()
        {
            IUserMessage response;
            EmbedBuilder initialBuilder;


            initialBuilder = EmbedHelper.GetDefaultEmbed(Context);
            initialBuilder.AddField(":video_game: Exiting game", "Please wait...");

            response = await ReplyAsync("", embed : initialBuilder.Build());

            try {
                EmbedBuilder    embed;
                ProcessProvider provider;


                provider = new ProcessProvider();
                embed    = EmbedHelper.GetDefaultEmbed(Context);
                embed.AddField(":robot: Stopping bot process", "Please wait...");

                _screenshotProvider.Stop();

                embed.AddField(":white_check_mark: Success", "The bot process has been stopped.");

                // Forcibly kill the GTA process.
                KillGTAProcess();

                embed.AddField("Process Killed", "The GTA 5 process is no longer running.");

                await response.ModifyAsync(msg => { msg.Embed = embed.Build(); msg.Content = ""; });
            } catch (Exception e) {
                await response.ModifyAsync(msg => msg = ErrorHandler.GetDefaultErrorMessageEmbed(e, msg, Context.Message));
            }
        }