Beispiel #1
0
        internal DiscordWebhook(DiscordHttpClient http, DiscordApiData data)
            : base(data)
        {
            this.http = http;

            GuildId   = data.GetSnowflake("guild_id").Value;
            ChannelId = data.GetSnowflake("channel_id").Value;

            DiscordApiData userData = data.Get("user");

            if (!userData.IsNull)
            {
                User = new DiscordUser(false, userData);
            }

            Name  = data.GetString("name");
            Token = data.GetString("token");

            string avatarHash = data.GetString("avatar");

            if (avatarHash != null)
            {
                Avatar = DiscordCdnUrl.ForUserAvatar(Id, avatarHash);
            }
        }
Beispiel #2
0
        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();
        }
Beispiel #3
0
        internal DiscordUser(MutableUser user)
        {
            Id            = user.Id;
            IsWebhookUser = user.IsWebhookUser;

            Username         = user.Username;
            Discriminator    = user.Discriminator;
            IsBot            = user.IsBot;
            HasTwoFactorAuth = user.HasTwoFactorAuth;
            IsVerified       = user.IsVerified;
            Email            = user.Email;

            if (user.Avatar != null)
            {
                Avatar = DiscordCdnUrl.ForUserAvatar(user.Id, user.Avatar);
            }
        }
Beispiel #4
0
        internal DiscordUser(bool isWebhookUser, DiscordApiData data)
            : base(data)
        {
            IsWebhookUser = isWebhookUser;

            Username         = data.GetString("username");
            Discriminator    = data.GetString("discriminator");
            IsBot            = data.GetBoolean("bot") ?? false;
            HasTwoFactorAuth = data.GetBoolean("mfa_enabled") ?? false;
            IsVerified       = data.GetBoolean("verified") ?? false;
            Email            = data.GetString("email");

            string avatarHash = data.GetString("avatar");

            if (avatarHash != null)
            {
                Avatar = DiscordCdnUrl.ForUserAvatar(Id, avatarHash);
            }
        }
Beispiel #5
0
        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();
        }
Beispiel #6
0
        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;
        }