示例#1
0
        public async Task GetNotInClanAsync()
        {
            var guildsMembers = Guild.GuildMembers;
            var clanMembers   = await Clash.GetClanMembersAsync(Guild.ClanTag);

            var notInClan = guildsMembers.Where(guildMember =>
                                                !guildMember.Tags.Any(x => clanMembers.Select(y => y.Tag).Any(z => z == x))).ToArray();

            await SendMessageAsync(string.Join('\n',
                                               notInClan.Select(x => Context.Guild.GetUser(x.Id)?.GetDisplayName()).Where(y => !(y is null))));
        }
示例#2
0
        public async Task DiscordCheck()
        {
            var clanMembers = await Clash.GetClanMembersAsync(Guild.ClanTag);

            var discordMembers = Guild.GuildMembers;

            var missingMembers = clanMembers.Where(clanMember => !discordMembers.Any(x =>
                                                                                     x.Tags.Any(y => string.Equals(y, clanMember.Tag, StringComparison.InvariantCultureIgnoreCase))))
                                 .ToArray();

            var missingList = string.Join('\n', missingMembers.Select(x => $"{x.Name}{x.Tag}"));

            await SendMessageAsync(missingList);
        }
示例#3
0
        public async Task ViewFrequentMissersAsync()
        {
            var guildMembers = Guild.GuildMembers;

            var clanMembers = await Clash.GetClanMembersAsync(Guild.ClanTag);

            var combined = (from clanMember in clanMembers
                            let foundGuildMember =
                                guildMembers.FirstOrDefault(guildMember => guildMember.Tags.Any(tag =>
                                                                                                string.Equals(tag, clanMember.Tag, StringComparison.InvariantCultureIgnoreCase)))
                                where !(foundGuildMember is null)
                                select(clanMember, foundGuildMember)).ToArray();

            var frequents = combined.Where(x =>
                                           (float)x.foundGuildMember.MissedAttacks / x.foundGuildMember.TotalWars > 0.5);

            var message = string.Join('\n',
                                      frequents.Select(x =>
                                                       $"{x.clanMember.Name}{x.clanMember.Tag} {x.foundGuildMember.MissedAttacks}/{x.foundGuildMember.TotalWars}"));

            await SendMessageAsync($"__**People with >50% missed attacks**__\n{message}");
        }
示例#4
0
        public async Task GetTagsAsync(SocketGuildUser user = null)
        {
            user = user ?? Context.User;

            var guildMember = Guild.GuildMembers.FirstOrDefault(x => x.Id == user.Id);

            if (guildMember is null)
            {
                await SendMessageAsync("You aren't verified");

                return;
            }

            var clanMembers = await Clash.GetClanMembersAsync(Guild.ClanTag);

            var matchingTags = (from tag in guildMember.Tags
                                let foundMember = clanMembers.FirstOrDefault(x => string.Equals(x.Tag, tag, StringComparison.InvariantCultureIgnoreCase))
                                                  select foundMember is null
                    ? $"{tag} - Not in clan"
                    : $"{foundMember.Tag} - {foundMember.Name}").ToList();

            await SendMessageAsync(string.Join('\n', matchingTags));
        }
示例#5
0
        public async Task SetNameAsync(string userTag)
        {
            var guildMember = Guild.GuildMembers.FirstOrDefault(x => x.Id == Context.User.Id); //TODO typereader

            if (guildMember is null)
            {
                await SendMessageAsync("You are not verified");

                return;
            }

            if (!guildMember.Tags.Any(x => string.Equals(x, userTag, StringComparison.InvariantCultureIgnoreCase)))
            {
                await SendMessageAsync("This tag is not registered to your account");

                return;
            }

            var clanMembers = await Clash.GetClanMembersAsync(Guild.ClanTag);

            var foundMember = clanMembers.FirstOrDefault(x =>
                                                         string.Equals(x.Tag, userTag, StringComparison.InvariantCultureIgnoreCase));

            if (foundMember is null)
            {
                await SendMessageAsync("This tag does not belong to the clan");

                return;
            }

            guildMember.MainTag = foundMember.Tag;

            Database.UpdateGuild();
            await Context.User.ModifyAsync(x => x.Nickname = foundMember.Name);

            await SendMessageAsync("Name has been set");
        }