TobiasDeBruijn / dwbhk-rs

Simple Discord Webhook library for Rust
Other
1 stars 0 forks source link

unused implementer of `Future` that must be used #1

Open natslol opened 2 years ago

natslol commented 2 years ago

I want to execute url but i got this so i think this is why the webhook doesnt send anything

image

this my code part using your lib

        println!("Webhook: ");
        let mut webhook: String = String::new();
        io::stdin().read_line(&mut webhook).expect("Impossible de lire le webhook");
        let webhook = webhook.trim();

        let req = WebhookRequestBuilder::new()
            .set_data(WebhookBuilder::new()
                .set_username("ok")
                .set_avatar_url("https://i.imgur.com/lspeP0T.png")
                .set_embeds(vec![
                        EmbedBuilder::new()
                            .set_title(username.trim())
                            .set_color_hex("#DC143C")
                            .set_description(description.trim())
                            .set_fields(vec![
                                    EmbedFieldBuilder::new()
                                        .set_name("ok")
                                        .set_value(ok.trim())
                                        .set_inline(true)
                                        .build()
                                ]
                            )
                            .build()
                        ]
                )
                .build()
            )
            .build();

        req.execute_url(&webhook);
TobiasDeBruijn commented 2 years ago

Hey there,

You're using async, so you need to await the future before it does anything. You can enable the blocking feature (refer to the docs) to use the non-async versions. Alternatively, to keep using async check out the Rust async docs.

If you have more questions feel free to reach out 😄

natslol commented 2 years ago

Hey,

Thanks for you reply and help but i have an another question i want to use EmbedImageBuilder like this :

                            .set_image(&EmbedImageBuilder::new().set_url("https://i.imgur.com/UTR1dfw.jpeg").build())
TobiasDeBruijn commented 2 years ago

Hm that indeed won't work due to the reference, giving a compiler error.

For now you can bind the EmbedImageBuilder to it's own variable. I'll make sure this gets fixed in 0.1.3.

Using the following:

fn main() {

    let image = EmbedImageBuilder::new()
        .set_url("https://i.imgur.com/UTR1dfw.jpeg")
        .build();

    let req = WebhookRequestBuilder::new()
        .set_data(WebhookBuilder::new()
            .set_embeds(vec![
                EmbedBuilder::new()
                    .set_image(&image)
                    .build()
            ])
            .build())
        .build();

    req.execute_url_sync("[redacted]").unwrap();
}

Results in: image

natslol commented 2 years ago

Thanks for your answer and i want to talk privatly can i have your discord ?

TobiasDeBruijn commented 2 years ago

Hey there,

Unfortunately my Discord is not available for the public 😅. If you have any questions regarding dwbhk I'm more than happy to help here though.

Happy coding 😄

natslol commented 2 years ago

Hey,

can we talking on twitter instead ?

natslol commented 2 years ago

And i have an another question why i can't use a content with an embed i want to ping everyone with an embed image rip don't mind about Field 😅

TobiasDeBruijn commented 2 years ago

And i have an another question why i can't use a content with an embed i want to ping everyone with an embed image rip don't mind about Field 😅

This is a Discord limitation

TobiasDeBruijn commented 2 years ago

Hey,

can we talking on twitter instead ?

Here is fine 😄

natslol commented 2 years ago

Rip my friend can with cpp why me i cant with rust ?

natslol commented 2 years ago

image

TobiasDeBruijn commented 2 years ago

Rip my friend can with cpp why me i cant with rust ?

The 'limitation' is mentioned in the Discord API docs. Thus I took over that limitation. It might work now, but it might no longer in the future, hence I've stuck to the API docs with dwbhk 😄

TobiasDeBruijn commented 2 years ago

image

As mentioned, please keep it here on GitHub. My Twitter is for my personal stuff, GitHub is for things related to my projects on GitHub.

natslol commented 2 years ago

image

As mentioned, please keep it here on GitHub. My Twitter is for my personal stuff, GitHub is for things related to my projects on GitHub.

Mmh okok sorry but anyone can see this :(, I Want to do screenshot but the crates don't work with what I want to do and and mostly it's OS issue.

TobiasDeBruijn commented 2 years ago

I'm not entirely sure what you mean.

natslol commented 2 years ago

I'm not entirely sure what you mean.

I want to do a Screenshot with Rust

TobiasDeBruijn commented 2 years ago

That should be possible, though I don't have a clue on where to start with taking screenshots. I'm not at all versed in the land of GUI.

If you have more questions related to the usage of dwbhk, please do let me know though :-)

natslol commented 2 years ago

I have a last question,

I want to add an image without url but with a file or a variable that contains the image in Vec<u8>

natslol commented 2 years ago

And how to content + embeds bc i need it :(

TobiasDeBruijn commented 2 years ago

Uploading files is currently not supported, as I never got around to implementing it. However you're more than welcome to open a PR for it. You'll want to look at the file[s] field in the API docs.