internal DiscordGuild(DiscordHttpClient http, MutableGuild guild) { this.http = http; Id = guild.Id; Name = guild.Name; RegionId = guild.RegionId; AfkTimeout = guild.AfkTimeout; IsEmbedEnabled = guild.IsEmbedEnabled; VerificationLevel = guild.VerificationLevel; MfaLevel = guild.MfaLevel; ApplicationId = guild.ApplicationId; IsWidgetEnabled = guild.IsWidgetEnabled; WidgetChannelId = guild.WidgetChannelId; SystemChannelId = guild.SystemChannelId; DefaultMessageNotifications = guild.DefaultMessageNotifications; ExplicitContentFilter = guild.ExplicitContentFilter; OwnerId = guild.OwnerId; AfkChannelId = guild.AfkChannelId; EmbedChannelId = guild.EmbedChannelId; MaxPresences = guild.MaxPresences; MaxMembers = guild.MaxMembers; VanityUrlCode = guild.VanityUrlCode; Description = guild.Description; PremiumTier = guild.PremiumTier; PremiumSubscriptionCount = guild.PremiumSubscriptionCount; PreferredLocale = guild.PreferredLocale; if (guild.Icon != null) { Icon = DiscordCdnUrl.ForGuildIcon(guild.Id, guild.Icon); } if (guild.Splash != null) { Splash = DiscordCdnUrl.ForGuildSplash(guild.Id, guild.Splash); } if (guild.Banner != null) { Splash = DiscordCdnUrl.ForGuildBanner(guild.Id, guild.Banner); } Features = new List <string>(guild.Features); Roles = guild.Roles.CreateReadonlyCopy(); Emojis = guild.Emojis.CreateReadonlyCopy(); }
internal DiscordGuild(DiscordHttpClient http, MutableGuild guild) { this.http = http; Id = guild.Id; Name = guild.Name; RegionId = guild.RegionId; AfkTimeout = guild.AfkTimeout; IsEmbedEnabled = guild.IsEmbedEnabled; VerificationLevel = guild.VerificationLevel; MfaLevel = guild.MfaLevel; ApplicationId = guild.ApplicationId; IsWidgetEnabled = guild.IsWidgetEnabled; WidgetChannelId = guild.WidgetChannelId; SystemChannelId = guild.SystemChannelId; DefaultMessageNotifications = guild.DefaultMessageNotifications; ExplicitContentFilter = guild.ExplicitContentFilter; OwnerId = guild.OwnerId; AfkChannelId = guild.AfkChannelId; EmbedChannelId = guild.EmbedChannelId; if (guild.Icon != null) { Icon = DiscordCdnUrl.ForGuildIcon(guild.Id, guild.Icon); } if (guild.Splash != null) { Splash = DiscordCdnUrl.ForGuildSplash(guild.Id, guild.Splash); } Features = new List <string>(guild.Features); Roles = guild.Roles.CreateReadonlyCopy(); Emojis = guild.Emojis.CreateReadonlyCopy(); }
internal DiscordGuild(DiscordHttpClient http, DiscordApiData data) : base(data) { this.http = http; Name = data.GetString("name"); RegionId = data.GetString("region"); AfkTimeout = data.GetInteger("afk_timeout").Value; IsEmbedEnabled = data.GetBoolean("embed_enabled") ?? false; OwnerId = data.GetSnowflake("owner_id").Value; AfkChannelId = data.GetSnowflake("afk_channel_id"); EmbedChannelId = data.GetSnowflake("embed_channel_id"); ApplicationId = data.GetSnowflake("application_id"); IsWidgetEnabled = data.GetBoolean("widget_enabled") ?? false; WidgetChannelId = data.GetSnowflake("widget_channel_id"); SystemChannelId = data.GetSnowflake("system_channel_id"); ExplicitContentFilter = (GuildExplicitContentFilterLevel)data.GetInteger("explicit_content_filter").Value; VerificationLevel = (GuildVerificationLevel)data.GetInteger("verification_level").Value; DefaultMessageNotifications = (GuildNotificationOption)(data.GetInteger("default_message_notifications") ?? 0); MfaLevel = (GuildMfaLevel)data.GetInteger("mfa_level").Value; // Get image hashes string iconHash = data.GetString("icon"); if (iconHash != null) { Icon = DiscordCdnUrl.ForGuildIcon(Id, iconHash); } string splashHash = data.GetString("splash"); if (splashHash != null) { Splash = DiscordCdnUrl.ForGuildSplash(Id, splashHash); } // Get features IList <DiscordApiData> featuresData = data.GetArray("features"); string[] features = new string[featuresData.Count]; for (int i = 0; i < features.Length; i++) { features[i] = featuresData[i].ToString(); } Features = features; // Get roles IList <DiscordApiData> rolesData = data.GetArray("roles"); Dictionary <Snowflake, DiscordRole> roles = new Dictionary <Snowflake, DiscordRole>(); for (int i = 0; i < rolesData.Count; i++) { DiscordRole role = new DiscordRole(http, Id, rolesData[i]); roles.Add(role.Id, role); } Roles = roles; // Get emojis IList <DiscordApiData> emojisArray = data.GetArray("emojis"); Dictionary <Snowflake, DiscordEmoji> emojis = new Dictionary <Snowflake, DiscordEmoji>(); for (int i = 0; i < emojisArray.Count; i++) { DiscordEmoji emoji = new DiscordEmoji(emojisArray[i]); emojis.Add(emoji.Id, emoji); } Emojis = emojis; }