Beispiel #1
0
        // TODO: Make channel concrete instead of a promise, and thus fix the cast error
        protected Message(JsonObjectReader r)
        {
            Id           = r.ReadSnowflake("id");
            ChannelId    = r.ReadSnowflake("channel_id");
            Channel      = new CachedPromise <TextChannel>(new AliasCache <IChannel, TextChannel>(ChannelUtils._globalCache), ChannelId, TextChannel.GetAsync);
            Content      = r.ReadString("content");
            CreationTime = DateTime.Parse(r.ReadString("timestamp"));
            string letStr = r.ReadNullableString("edited_timestamp"); if (letStr != null)

            {
                LastEditTime = (DateTime?)DateTime.Parse(letStr);
            }

            IsTextToSpeech    = r.ReadBoolean("tts");
            MentionedEveryone = r.ReadBoolean("mention_everyone");
            MentionedUsers    = r.ReadObjectArray <UserJson>("mentions").Select(x => User.CreateFromJson(x, null)).ToIdDic();
            MentionedRoles    = r.ReadObjectArray <RoleJson>("mention_roles").Select(x => Role.CreateFromJson(((IServerChannel)Channel.GetCachedValue()).ServerId, x, null)).ToIdDic();
            IsPinned          = r.ReadBoolean("pinned");
            MsgType           = (InternalMessageType)r.ReadInt32("type");
            _cache.Add(this);
        }