Пример #1
0
        private async Task PostTasks(JsonServer server)
        {
            var authBuilder = new EmbedAuthorBuilder()
            {
                Name    = $"Download Playtest Demo for {_mod.TestInfo[2]}",
                IconUrl = "https://cdn.discordapp.com/icons/111951182947258368/0e82dec99052c22abfbe989ece074cf5.png",
            };

            var builder = new EmbedBuilder()
            {
                Author       = authBuilder,
                Url          = "http://demos.tophattwaffle.com",
                Title        = "Download Here",
                ThumbnailUrl = _mod.TestInfo[4],
                Color        = new Color(243, 128, 72),
                Description  = $"You can get the demo for this playtest by clicking above!" +
                               $"\n\n*Thanks for testing with us!*" +
                               $"\n\n[Map Images]({_mod.TestInfo[5]}) | [Schedule a Playtest](https://www.tophattwaffle.com/playtesting/) | [View Testing Calendar](http://playtesting.tophattwaffle.com)"
            };

            var result = Regex.Match(_mod.TestInfo[6], @"\d+$").Value;
            await _dataServices.RconCommand($"host_workshop_map {result}", server);

            await Task.Delay(15000);

            await _dataServices.RconCommand($"exec {_dataServices.postConfig}; say Please join the Level Testing voice channel for feedback!", server);

            await Task.Delay(3000);

            await _dataServices.RconCommand($"sv_voiceenable 0; say Please join the Level Testing voice channel for feedback!", server);

            await Task.Delay(3000);

            await _dataServices.RconCommand($"say Please join the Level Testing voice channel for feedback!", server);

            await Task.Delay(3000);

            await _dataServices.RconCommand($"say Please join the Level Testing voice channel for feedback!", server);

            await Task.Delay(3000);

            await _dataServices.RconCommand($"say Please join the Level Testing voice channel for feedback!", server);

            // Starts downloading playtesting files in the background.
            downloaderSvc.Start(_mod.TestInfo, server);

            var splitUser = _mod.TestInfo[3].Split('#');

            try
            {
                //Try to DM them the information to get their demos.
                await Program._client.GetUser(splitUser[0], splitUser[1]).SendMessageAsync("", false, builder);
            }
            catch
            {
                try
                {
                    //If they don't accepts DMs, tag them in level testing.
                    await _dataServices.testingChannel.SendMessageAsync($"{Program._client.GetUser(splitUser[0], splitUser[1]).Mention} You can download your demo here:");
                }
                catch
                {
                    //If it cannot get the name from the event info, nag them in level testing.
                    await _dataServices.testingChannel.SendMessageAsync($"Hey {_mod.TestInfo[3]}! Next time you submit for a playtest, make sure to include your full Discord name so I can mention you. You can download your demo here:");
                }
            }
            await _dataServices.testingChannel.SendMessageAsync($"", false, builder);
        }