Esempio n. 1
0
        public async Task AddUsersAsync([Summary("Id of the raid")] string raidId, params string[] users)
        {
            if (_raidService.TryFindRaid(raidId, out Raid raid))
            {
                if (users.Length % 3 != 0)
                {
                    await Context.Channel.SendMessageAsync("wrong number of parameters.");
                }
                Constants.Availability availability = Constants.Availability.Yes;
                string resultMessage = string.Empty;
                for (int i = 0; i < users.Length; i += 3)
                {
                    string userName    = users[i];
                    string role        = users[i + 1];
                    string usedAccount = users[i + 2];

                    foreach (SocketUser user in Context.Message.MentionedUsers)
                    {
                        if (user.Mention == userName && user is IGuildUser guildUser)
                        {
                            _raidService.AddUser(raidId, guildUser, role, availability, usedAccount, out resultMessage);
                        }
                    }
                }
                await Context.Channel.SendMessageAsync(resultMessage);

                IUserMessage userMessage = (IUserMessage)await Context.Guild.GetTextChannel(raid.ChannelId).GetMessageAsync(raid.MessageId);

                await userMessage.ModifyAsync(msg => msg.Embed = raid.CreateRaidMessage());
            }
            await Context.Message.DeleteAsync();
        }
Esempio n. 2
0
        private bool AddUser(string raidId, User user, string role, Constants.Availability availability, out string resultMessage)
        {
            if (!Raids.ContainsKey(raidId))
            {
                resultMessage = "raid not found";
                return(false);
            }
            Raid raid = Raids[raidId];

            if (!raid.CheckRoleAvailability(user.DiscordId, role, availability, out resultMessage))
            {
                return(false);
            }

            if (availability.Equals(Constants.Availability.Flex))
            {
                raid.FlexRoles.Add(user);
            }
            else
            {
                raid.Users.Add(user.DiscordId, user);
            }
            SaveRaids();
            resultMessage = "Added to raid roster";
            return(true);
        }
Esempio n. 3
0
 private SignUpConversation(ConversationService conversationService, RaidService raidService, UserService userService, ISocketMessageChannel channel, IGuildUser user, Raid raid, Constants.Availability availability) : base(conversationService, user)
 {
     _user              = user;
     _channel           = channel;
     this._raid         = raid;
     this._availability = availability;
     _raidService       = raidService;
     _userService       = userService;
     _state             = State.role;
 }
Esempio n. 4
0
        public bool AddUser(string raidId, IGuildUser user, string role, Constants.Availability availability, string usedAccount, out string resultMessage)
        {
            string nickname = _userService.GetUserName(user.GuildId, user.Id);

            if (string.IsNullOrEmpty(nickname))
            {
                nickname = user.Nickname ?? user.Username;
            }
            User raidUser = new User(role, availability, nickname, usedAccount, user.Id);

            return(AddUser(raidId, raidUser, role, availability, out resultMessage));
        }
Esempio n. 5
0
        public bool AddUser(string raidId, string userName, string role, Constants.Availability availability, out string resultMessage)
        {
            if (!Raids.ContainsKey(raidId))
            {
                resultMessage = "raid not found";
                return(false);
            }
            Raid raid     = Raids[raidId];
            User raidUser = new User(role, availability, userName, userName, raid.GetFreeUserId());

            return(AddUser(raidId, raidUser, role, availability, out resultMessage));
        }
Esempio n. 6
0
        public async Task AddExternalUserAsync([Summary("Id of the raid")] string raidId, [Summary("The name of the user")] string userName, [Summary("The role the user wants to play")] string role, [Summary("Availability of the user")] string availability = "")
        {
            if (_raidService.TryFindRaid(raidId, out Raid raid))
            {
                Constants.Availability availabilityEnum = Constants.Availability.Yes;
                switch (availability.ToLower())
                {
                case "maybe":
                    availabilityEnum = Constants.Availability.Maybe;
                    break;

                case "backup":
                    availabilityEnum = Constants.Availability.Backup;
                    break;
                }
                _raidService.AddUser(raidId, userName, role, availabilityEnum, out string resultMessage);
                await Context.Channel.SendMessageAsync(resultMessage);

                IUserMessage userMessage = (IUserMessage)await Context.Guild.GetTextChannel(raid.ChannelId).GetMessageAsync(raid.MessageId);

                await userMessage.ModifyAsync(msg => msg.Embed = raid.CreateRaidMessage());
            }
            await Context.Message.DeleteAsync();
        }
Esempio n. 7
0
 public async void OpenSignUpConversation(RaidService raidService, SocketReaction reaction, IGuildUser user, Raid raid, Constants.Availability availability)
 {
     _conversations.Add(user.Id, await SignUpConversation.Create(this, raidService, _userService, _logService, reaction, user, raid, availability));
 }
Esempio n. 8
0
        public static async Task <SignUpConversation> Create(ConversationService conversationService, RaidService raidService, UserService userService, SocketReaction reaction, IGuildUser user, Raid raid, Constants.Availability availability)
        {
            //Create Conversation
            SignUpConversation conversation = new SignUpConversation(conversationService, raidService, userService, reaction.Channel, user, raid, availability);

            //remiove reaction
            IUserMessage userMessage = (IUserMessage)await conversation._channel.GetMessageAsync(conversation._raid.MessageId);

            await userMessage.RemoveReactionAsync(reaction.Emote, conversation._user);

            //send sign up message
            if (reaction.Emote.Equals(Constants.FlexEmoji))
            {
                await UserExtensions.SendMessageAsync(conversation._user, CreateFlexRoleMessage(conversation._raid));
            }
            else
            {
                await UserExtensions.SendMessageAsync(conversation._user, CreateSignUpMessage(conversation._raid));
            }
            return(conversation);
        }