Beispiel #1
0
        /// <summary>
        ///     Populate the input guilds with details.
        /// </summary>
        /// <param name="guilds">Input list of guilds.</param>
        /// <param name="detailsGuildId">If specified, will only provide details for the guild with the specified id.</param>
        /// <returns>Populated list of guilds.</returns>
        private List <UserGuild> GetGuildDetails(List <UserGuild> guilds, ulong?detailsGuildId = null)
        {
            foreach (var guild in guilds)
            {
                // We only want the details for the specified guild so skip the rest.
                if (detailsGuildId != null && guild.Guild.Id != detailsGuildId)
                {
                    continue;
                }

                var guildId = guild.Guild.Id;

                guild.Guild.Details.IsBotInGuild = _bot.IsBotInGuild(guild.Guild.Id);

                // Set the Volvox logo as the image if the guild does not have an icon.
                if (string.IsNullOrWhiteSpace(guild.Guild.Icon))
                {
                    guild.Guild.ImageUrl = "/images/small/volvox-logo.png";
                }

                // Bot must be in the guild to retrieve details.
                if (guild.Guild.Details.IsBotInGuild)
                {
                    var botGuild = _bot.GetGuild(guildId);

                    guild.Guild.Details.MemberCount = botGuild.MemberCount;
                    guild.Guild.Details.Roles       = botGuild.Roles;
                    guild.Guild.Details.Channels    = botGuild.Channels;
                }
            }

            return(guilds);
        }