Exemple #1
0
        internal DiscordGame(DiscordApiData data)
        {
            Name          = data.GetString("name");
            Type          = (DiscordGameType)(data.GetInteger("type") ?? 0);
            Url           = data.GetString("url");
            CreatedAt     = data.GetInt64("created_at");
            ApplicationId = data.GetSnowflake("application_id");
            Details       = data.GetString("details");
            State         = data.GetString("state");
            Instance      = data.GetBoolean("instance");
            Flags         = (DiscordActivityFlag)(data.GetInteger("flags") ?? 0);

            DiscordApiData timestampsData = data.Get("timestamps");

            if (timestampsData != null)
            {
                Timestamps = new DiscordActivityTimestamps(timestampsData);
            }

            DiscordApiData emojiData = data.Get("emoji");

            if (emojiData != null)
            {
                Emoji = new DiscordActivityEmoji(emojiData);
            }

            DiscordApiData partyData = data.Get("party");

            if (partyData != null)
            {
                Party = new DiscordActivityParty(partyData);
            }

            DiscordApiData assetsData = data.Get("assets");

            if (assetsData != null)
            {
                Assets = new DiscordActivityAssets(assetsData);
            }

            DiscordApiData secretsData = data.Get("secrets");

            if (secretsData != null)
            {
                Secrets = new DiscordActivitySecrets(secretsData);
            }

            IList <DiscordApiData> buttonsArray = data.GetArray("buttons");

            if (buttonsArray != null)
            {
                Buttons = buttonsArray.Select(d => d.ToString()).ToArray();
            }
        }
Exemple #2
0
        internal DiscordOverwrite(DiscordHttpClient http, Snowflake channelId, DiscordApiData data)
            : base(data)
        {
            this.http = http;

            ChannelId = channelId;

            string typeStr = data.GetString("type");
            DiscordOverwriteType type;

            if (Enum.TryParse(typeStr, true, out type))
            {
                Type = type;
            }

            long allow = data.GetInt64("allow").Value;

            Allow = (DiscordPermission)allow;

            long deny = data.GetInt64("deny").Value;

            Deny = (DiscordPermission)deny;
        }
Exemple #3
0
        internal DiscordRole(DiscordHttpClient http, Snowflake guildId, DiscordApiData data)
            : base(data)
        {
            this.http = http;

            GuildId = guildId;

            Name          = data.GetString("name");
            IsHoisted     = data.GetBoolean("hoist").Value;
            Position      = data.GetInteger("position").Value;
            IsManaged     = data.GetBoolean("managed").Value;
            IsMentionable = data.GetBoolean("mentionable").Value;

            int color = data.GetInteger("color").Value;

            Color = DiscordColor.FromHexadecimal(color);

            long permissions = data.GetInt64("permissions").Value;

            Permissions = (DiscordPermission)permissions;
        }