Exemple #1
0
        public async Task <bool> InspectAsync()
        {
            if (!_contextService.IsManagement)
            {
                return(false);
            }

            var entries = _embeds.All();

            if (entries.Count() == 0)
            {
                await ReplyAsync("No information found.");

                return(true);
            }

            var fields = new List <EmbedFieldBuilder>()
            {
                new EmbedFieldBuilder()
                .WithName("Number of entries")
                .WithValue(entries.Count())
            };

            var byGuild = entries.Select(x => (Guild: _clientService.Client.GetGuild(ulong.Parse(x.Guild)).Name, x.Slug))
                          .GroupBy(x => x.Guild)
                          .ToDictionary(o => o.Key, o => o.ToList());

            foreach (var(guild, mappedEntries) in byGuild)
            {
                fields.Add(new EmbedFieldBuilder()
                           .WithName(guild)
                           .WithValue(string.Join(", ", mappedEntries.Select(x => x.Slug))));
            }

            var reply = new EmbedBuilder()
                        .WithTitle("Global info")
                        .WithFields(fields);

            await ReplyAsync(embed : reply.Build());

            return(true);
        }