public Playtest(PlaytestRequest playtestRequest)
 {
     TestType  = (int)TypeOfTest.Requested;
     TestName  = playtestRequest.MapName;
     StartTime = playtestRequest.TestDate;
     Game      = playtestRequest.Game;
 }
Exemplo n.º 2
0
        public RequestBuilder(SocketCommandContext context, InteractiveService interactive, DataService data,
                              LogHandler log,
                              GoogleCalendar calendar, PlaytestService playtestService)
        {
            _context         = context;
            _interactive     = interactive;
            _dataService     = data;
            _log             = log;
            _calendar        = calendar;
            _playtestService = playtestService;

            //Make the test object
            _testRequest    = new PlaytestRequest();
            _isDms          = context.IsPrivate;
            _workshop       = new Workshop(_dataService, _log);
            _otherRequests  = null;
            _scheduledTests = null;
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Entry point for moderation staff to work with playtest requests.
        /// </summary>
        /// <param name="display">The embed message to attach to for displaying updates</param>
        /// <returns></returns>
        public async Task SchedulePlaytestAsync(IUserMessage display)
        {
            var playtestRequests = DatabaseUtil.GetAllPlaytestRequests().ToList();

            _embedMessage = display;

            //If there are no requests, don't enter interactive mode. Just return
            if (playtestRequests.Count == 0)
            {
                return;
            }

            await _embedMessage.ModifyAsync(x => x.Content = "Type `exit` to abort at any time.");

            _instructionsMessage = await _context.Channel.SendMessageAsync("Type the ID of the playtest to schedule.");

            //Finds the correct playtest request to work with.
            var id = 0;

            while (true)
            {
                _userMessage = await _interactive.NextMessageAsync(_context);

                if (_userMessage == null ||
                    _userMessage.Content.Equals("exit", StringComparison.OrdinalIgnoreCase))
                {
                    await CancelRequest();

                    return;
                }

                if (int.TryParse(_userMessage.Content, out id) && id >= 0 && id < playtestRequests.Count)
                {
                    break;
                }

                await _userMessage.DeleteAsync();
            }

            //Set the request based on the chosen request.
            _testRequest = playtestRequests[id];

            await ConfirmSchedule();
        }
        public async Task UserEditRequest(PlaytestRequest existingRequest)
        {
            _testRequest = existingRequest;

            while (true)
            {
                _instructionsMessage = await _context.Message.Channel.SendMessageAsync(
                    $"I found an existing playtest request for `{_testRequest.MapName}`." +
                    "\nType `edit` to edit this request." +
                    "\nType `delete` to delete this request." +
                    "\nType `exit` to abort.");

                _userMessage = await _interactive.NextMessageAsync(_context);

                if (_userMessage == null ||
                    _userMessage.Content.Equals("exit", StringComparison.OrdinalIgnoreCase))
                {
                    await CancelRequest();

                    return;
                }

                if (_userMessage.Content.Equals("edit", StringComparison.OrdinalIgnoreCase))
                {
                    _wasEdit = true;
                    await _instructionsMessage.DeleteAsync();

                    _instructionsMessage = null;
                    await ConfirmRequest();

                    return;
                }

                if (_userMessage.Content.Equals("delete", StringComparison.OrdinalIgnoreCase))
                {
                    await DeleteRequest();

                    return;
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Adds a test event to the testing calendar.
        /// </summary>
        /// <param name="playtestRequest">Playtest request to add</param>
        /// <param name="moderator">Moderator for the test</param>
        /// <returns>True if successful, false otherwise.</returns>
        public async Task <bool> AddTestEvent(PlaytestRequest playtestRequest, SocketUser moderator)
        {
            string creators = null;

            foreach (var creator in playtestRequest.CreatorsDiscord)
            {
                var user = _dataService.GetSocketUser(creator);
                if (user != null)
                {
                    creators += $"{user.Username}, ";
                }
                else
                {
                    creators += $"Unknown[{creator}]";
                }
            }

            //Create list and add the required attendee.
            var attendeeLists = new List <EventAttendee>();

            //Add every other user's email
            foreach (var email in playtestRequest.Emails)
            {
                if (!string.IsNullOrWhiteSpace(email))
                {
                    attendeeLists.Add(new EventAttendee {
                        Email = email
                    });
                }
            }

            var description = $"Creator: {string.Join(", ", playtestRequest.CreatorsDiscord)}\n" +
                              $"Map Images: {playtestRequest.ImgurAlbum}\n" +
                              $"Workshop Link: {playtestRequest.WorkshopURL}\n" +
                              $"Game Mode: {playtestRequest.TestType}\n" +
                              $"Moderator: {moderator.Id}\n" +
                              $"Description: {playtestRequest.TestGoals}";

            var newEvent = new Event
            {
                Summary =
                    $"{playtestRequest.Game.ToUpper()} | {playtestRequest.MapName} by {creators.TrimEnd(',', ' ')}",
                Location    = playtestRequest.Preferredserver,
                Description = description,
                Start       = new EventDateTime
                {
                    DateTime = playtestRequest.TestDate,
                    TimeZone = "America/Chicago"
                },
                End = new EventDateTime
                {
                    DateTime = playtestRequest.TestDate.AddHours(2),
                    TimeZone = "America/Chicago"
                },
                Attendees = attendeeLists
            };

            try
            {
                var request      = _calendar.Events.Insert(newEvent, _dataService.RSettings.ProgramSettings.TestCalendarId);
                var createdEvent = await request.ExecuteAsync();
            }
            catch (Exception e)
            {
                await _log.LogMessage($"Issue added test event to calendar!\n{e.Message}", color : LOG_COLOR);

                return(false);
            }

            return(true);
        }