Exemplo n.º 1
0
        public IReadOnlyDictionary <string, object> ToDictionary()
        {
            var d = new Dictionary <string, object>();

            d["file"] = new MultipartFile(File, Filename.GetValueOrDefault("unknown.dat"));
            if (Content.IsSpecified)
            {
                d["content"] = Content.Value;
            }
            if (IsTTS.IsSpecified)
            {
                d["tts"] = IsTTS.Value.ToString();
            }
            if (Nonce.IsSpecified)
            {
                d["nonce"] = Nonce.Value;
            }
            if (Username.IsSpecified)
            {
                d["username"] = Username.Value;
            }
            if (AvatarUrl.IsSpecified)
            {
                d["avatar_url"] = AvatarUrl.Value;
            }
            return(d);
        }
        public IReadOnlyDictionary <string, object> ToDictionary()
        {
            var d = new Dictionary <string, object>();

            d["file"] = new MultipartFile(File, Filename.GetValueOrDefault("unknown.dat"));

            var payload = new Dictionary <string, object>();

            if (Content.IsSpecified)
            {
                payload["content"] = Content.Value;
            }
            if (IsTTS.IsSpecified)
            {
                payload["tts"] = IsTTS.Value.ToString();
            }
            if (Nonce.IsSpecified)
            {
                payload["nonce"] = Nonce.Value;
            }
            if (Embed.IsSpecified)
            {
                payload["embed"] = Embed.Value;
            }

            var json = new StringBuilder();

            using (var text = new StringWriter(json))
                using (var writer = new JsonTextWriter(text))
                    _serializer.Serialize(writer, payload);

            d["payload_json"] = json.ToString();

            return(d);
        }
Exemplo n.º 3
0
        public IReadOnlyDictionary <string, object> ToDictionary()
        {
            var d        = new Dictionary <string, object>();
            var filename = Filename.GetValueOrDefault("unknown.dat");

            if (IsSpoiler && !filename.StartsWith(AttachmentExtensions.SpoilerPrefix))
            {
                filename = filename.Insert(0, AttachmentExtensions.SpoilerPrefix);
            }

            d["file"] = new MultipartFile(File, filename);

            var payload = new Dictionary <string, object>();

            if (Content.IsSpecified)
            {
                payload["content"] = Content.Value;
            }
            if (IsTTS.IsSpecified)
            {
                payload["tts"] = IsTTS.Value.ToString();
            }
            if (Nonce.IsSpecified)
            {
                payload["nonce"] = Nonce.Value;
            }
            if (Username.IsSpecified)
            {
                payload["username"] = Username.Value;
            }
            if (AvatarUrl.IsSpecified)
            {
                payload["avatar_url"] = AvatarUrl.Value;
            }
            if (Embeds.IsSpecified)
            {
                payload["embeds"] = Embeds.Value;
            }
            if (AllowedMentions.IsSpecified)
            {
                payload["allowed_mentions"] = AllowedMentions.Value;
            }
            if (Flags.IsSpecified)
            {
                payload["flags"] = Flags.Value;
            }

            var json = new StringBuilder();

            using (var text = new StringWriter(json))
                using (var writer = new JsonTextWriter(text))
                    _serializer.Serialize(writer, payload);

            d["payload_json"] = json.ToString();

            return(d);
        }
Exemplo n.º 4
0
        public IReadOnlyDictionary <string, object> ToDictionary()
        {
            Dictionary <string, object> d = new Dictionary <string, object>();
            string filename = Filename.GetValueOrDefault("unknown.dat");

            if (IsSpoiler && !filename.StartsWith(AttachmentExtensions.SpoilerPrefix))
            {
                filename = filename.Insert(0, AttachmentExtensions.SpoilerPrefix);
            }
            d["file"] = new MultipartFile(File, filename);

            Dictionary <string, object> payload = new Dictionary <string, object>();

            if (Content.IsSpecified)
            {
                payload["content"] = Content.Value;
            }
            if (IsTTS.IsSpecified)
            {
                payload["tts"] = IsTTS.Value.ToString();
            }
            if (Nonce.IsSpecified)
            {
                payload["nonce"] = Nonce.Value;
            }
            if (Embed.IsSpecified)
            {
                payload["embed"] = Embed.Value;
            }
            if (AllowedMentions.IsSpecified)
            {
                payload["allowed_mentions"] = AllowedMentions.Value;
            }
            if (IsSpoiler)
            {
                payload["hasSpoiler"] = IsSpoiler.ToString();
            }
            if (MessageReference.IsSpecified)
            {
                payload["message_reference"] = MessageReference.Value;
            }
            if (Components.IsSpecified)
            {
                payload["components"] = Components.Value;
            }

            StringBuilder json = new StringBuilder();

            using (StringWriter text = new StringWriter(json))
                using (JsonTextWriter writer = new JsonTextWriter(text))
                    _serializer.Serialize(writer, payload);

            d["payload_json"] = json.ToString();

            return(d);
        }