Ejemplo n.º 1
0
        public async Task ProcessRolesAsync(string message)
        {
            if (message.Equals("done", StringComparison.OrdinalIgnoreCase))
            {
                try
                {
                    ulong raidId = await _raidService.PostRaidMessageAsync(_channel, _raid);

                    _raidService.AddRaid(_raid, _guild.Id, _channel.Id, raidId);
                    await UserExtensions.SendMessageAsync(_user, "Created the raid successfully.");
                }
                catch { }
                finally
                {
                    _conversationService.CloseConversation(_user.Id);
                }
                return;
            }
            string invalidFormatMessage = "Invalid format. (format: [amount]:[Role name]). Type \"done\" to finish entering roles:";

            try
            {
                if (!Parsers.TryParseRole(message, out int noPositions, out string roleName, out string roleDescription))
                {
                    await UserExtensions.SendMessageAsync(_user, invalidFormatMessage);

                    return;
                }
                if (_raid.AddRole(noPositions, roleName, roleDescription))
                {
                    await UserExtensions.SendMessageAsync(_user, "Role added, please enter the next role or type \"done\"");
                }
                else
                {
                    await UserExtensions.SendMessageAsync(_user, "Adding of the role failed! Maybe it did already exist.\nPlease enter the next role or type \"done\"");
                }
            }
            catch
            {
                await UserExtensions.SendMessageAsync(_user, invalidFormatMessage);
            }
        }
Ejemplo n.º 2
0
        protected override async Task ProcessUncanceledMessage(string message)
        {
            switch (_state)
            {
            case State.creation:
                if (await CreateRaid(message))
                {
                    string       previewMessage = $"Raid preview: react with {Constants.SignOnEmoji} to create the raid or with {Constants.SignOffEmoji} to cancel.";
                    IUserMessage raidMessage    = await UserExtensions.SendMessageAsync(_user, previewMessage, embed : _raid.CreateRaidMessage());

                    await raidMessage.AddReactionAsync(Constants.SignOnEmoji);

                    await raidMessage.AddReactionAsync(Constants.SignOffEmoji);

                    _state = State.acception;
                }
                else
                {
                    await UserExtensions.SendMessageAsync(_user, $"Creation of the raid failed.");

                    _conversationService.CloseConversation(_user.Id);
                }
                break;

            case State.acception:
                if (message.Equals(Constants.SignOnEmoji.Name))
                {
                    ulong raidId = await _raidService.PostRaidMessageAsync(_channel, _raid);

                    _raidService.AddRaid(_raid, _guild.Id, _channel.Id, raidId);
                    await UserExtensions.SendMessageAsync(_user, "Created the raid successfully.");
                }
                else
                {
                    await UserExtensions.SendMessageAsync(_user, $"Creation of the raid canceled.");
                }
                _conversationService.CloseConversation(_user.Id);
                break;
            }
        }