コード例 #1
0
        public async Task Invite([Summary("List of users to invite, separated by spaces.")][Remainder] string invites)
        {
            ulong             raidMessageId = Context.Message.Reference.MessageId.Value;
            SocketUserMessage raidMessage   = (SocketUserMessage)await Context.Channel.GetMessageAsync(raidMessageId);

            RaidParent parent = raidMessages[raidMessageId];

            if (parent.IsInRaid((SocketGuildUser)Context.Message.Author, false) != Global.NOT_IN_RAID)
            {
                if (!parent.HasActiveInvite())
                {
                    parent.InvitingPlayer = (SocketGuildUser)Context.Message.Author;

                    List <string> inviteList = invites.Split(' ').ToList();
                    inviteList.RemoveAll(x => x.StartsWith("<@", StringComparison.OrdinalIgnoreCase));

                    List <SocketUser> mentioned = Context.Message.MentionedUsers.ToList();
                    bool failedInvites          = false;

                    foreach (string openInvite in inviteList)
                    {
                        SocketGuildUser invite = Context.Guild.Users.FirstOrDefault(x => x.Username.Equals(openInvite, StringComparison.OrdinalIgnoreCase) || (
                                                                                        x.Nickname != null && x.Nickname.Equals(openInvite, StringComparison.OrdinalIgnoreCase)));
                        if (invite != null && !mentioned.Contains(invite))
                        {
                            mentioned.Add(invite);
                        }
                        else
                        {
                            failedInvites = true;
                        }
                    }

                    foreach (SocketUser invite in mentioned)
                    {
                        if (parent.InvitePlayer((SocketGuildUser)invite, parent.InvitingPlayer))
                        {
                            await invite.SendMessageAsync($"You have been invited to a raid by {parent.InvitingPlayer.Nickname ?? parent.InvitingPlayer.Username}.");
                        }
                        else
                        {
                            failedInvites = true;
                        }
                    }

                    if (failedInvites)
                    {
                        await ResponseMessage.SendWarningMessage(Context.Channel, "invite", "Some users where not found to be invited");
                    }
                    await ModifyMessage(raidMessage, parent);

                    parent.InvitingPlayer = null;
                }
            }
            await Context.Message.DeleteAsync();
        }
コード例 #2
0
        public async Task Remote([Summary("Amount of users raiding remotly 0 - 6.")] int groupSize)
        {
            ulong             raidMessageId = Context.Message.Reference.MessageId.Value;
            SocketUserMessage raidMessage   = (SocketUserMessage)await Context.Channel.GetMessageAsync(raidMessageId);

            RaidParent parent = raidMessages[raidMessageId];

            if (!(parent is Raid raid))
            {
                await ResponseMessage.SendErrorMessage(Context.Channel, "remote", $"Command must be a reply to a raid or raid train message.");
            }
コード例 #3
0
        public async Task Request()
        {
            ulong             raidMessageId = Context.Message.Reference.MessageId.Value;
            SocketUserMessage raidMessage   = (SocketUserMessage)await Context.Channel.GetMessageAsync(raidMessageId);

            RaidParent parent = raidMessages[raidMessageId];

            parent.RequestInvite((SocketGuildUser)Context.Message.Author);
            await ModifyMessage(raidMessage, parent);

            await Context.Message.DeleteAsync();
        }
コード例 #4
0
        public async Task Edit([Summary("Portion of the raid message to edit.")] string attribute,
                               [Summary("New value of the edited attribute.")][Remainder] string value)
        {
            ulong             raidMessageId = Context.Message.Reference.MessageId.Value;
            SocketUserMessage raidMessage   = (SocketUserMessage)await Context.Channel.GetMessageAsync(raidMessageId);

            RaidParent parent = raidMessages[raidMessageId];

            if (!parent.IsSingleStop() && !Context.Message.Author.Equals(parent.Conductor))
            {
                await ResponseMessage.SendErrorMessage(raidMessage.Channel, "edit", $"Command can only be run by the current conductor.");
            }
            else
            {
                ISocketMessageChannel channel = raidMessage.Channel;
                bool needsEdit = false;
                if (attribute.Equals("time", StringComparison.OrdinalIgnoreCase))
                {
                    parent.UpdateRaidInformation(value, null);
                    needsEdit = true;
                }
                else if (attribute.Equals("location", StringComparison.OrdinalIgnoreCase) || attribute.Equals("loc", StringComparison.OrdinalIgnoreCase))
                {
                    parent.UpdateRaidInformation(null, value);
                    needsEdit = true;
                }
                else if (attribute.Equals("tier", StringComparison.OrdinalIgnoreCase) || attribute.Equals("boss", StringComparison.OrdinalIgnoreCase))
                {
                    short calcTier = Global.RAID_TIER_STRING.ContainsKey(value) ? Global.RAID_TIER_STRING[value] : Global.INVALID_RAID_TIER;

                    if (calcTier == Global.INVALID_RAID_TIER)
                    {
                        await ResponseMessage.SendErrorMessage(channel, "edit", $"No raid bosses found for tier {value}.");
                    }
                    else
                    {
                        SocketGuildUser author = (SocketGuildUser)Context.Message.Author;
                        if (parent.IsSingleStop())
                        {
                            parent.BossEditingPlayer = author;
                        }
                        parent.SelectionTier = calcTier;
                        RestUserMessage bossMsg = await Context.Channel.SendMessageAsync(text : $"{author.Mention}",
                                                                                         embed : BuildBossSelectEmbed(parent.AllBosses[calcTier], null, true));

                        subMessages.Add(bossMsg.Id, new RaidSubMessage((int)SUB_MESSAGE_TYPES.EDIT_BOSS_SUB_MESSAGE, raidMessage.Id));
                        IEmote[] emotes = Global.SELECTION_EMOJIS.Take(parent.AllBosses[calcTier].Count).ToArray();
                        bossMsg.AddReactionsAsync(emotes.Append(extraEmojis[(int)EXTRA_EMOJI_INDEX.CHANGE_TIER]).Append(extraEmojis[(int)EXTRA_EMOJI_INDEX.CANCEL]).ToArray());
                    }
                }
                else
                {
                    await ResponseMessage.SendErrorMessage(channel, "edit", "Please enter a valid field to edit.");
                }

                if (needsEdit)
                {
                    await ModifyMessage(raidMessage, parent);

                    await Context.Channel.SendMessageAsync(BuildEditPingList(parent.GetAllUsers().ToImmutableList(), (SocketGuildUser)Context.Message.Author, attribute, value));
                }
            }
            await Context.Message.DeleteAsync();
        }