SpaceManiac / discord-rs

Rust library for the Discord chat client API
MIT License
390 stars 94 forks source link

Add method to send 'embed' content. #88

Closed mmirate closed 7 years ago

mmirate commented 7 years ago

Add a Discord::send_embed method.

This method takes a closure for building some contents for the "embed" field of the "Create Messages" REST endpoint. Other send_* methods are unaffected.

A large number of new builder-pattern structs are added in order to avoid needing to either (a) publicise the underlying "Value" enum from serde, or (b) use a very large number of Option-valued method parameters.

I believe this should fix #86.

SpaceManiac commented 7 years ago

Thanks! Looks clean on a first glance. I will review thoroughly when I can.

SpaceManiac commented 7 years ago

zey reports that all height, width, and proxy_url values cannot actually be set by the sender. Can you confirm, and if so, remove those setters?

mmirate commented 7 years ago

Those setters are now removed, by amending.

Also, since this left two of the inner builder-structs with only one setter each (url), I eliminated those two and changed the image and thumbnail methods to each take a &str instead of a closure.

iddm commented 7 years ago

I am very excited to use this. Thanks for your work, @mmirate ! I have waited this for a long time. Can't wait till @SpaceManiac merges this.

SpaceManiac commented 7 years ago

Merged in 4bfe850dd2d9cf365a68ac47c31081a0e297e388. Thanks!

iddm commented 7 years ago

Though this is already closed, I think it makes sense to add more documentation for send_embed method which clearly explains how to use it (see usage).