Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable use send_file, "Invalid scheme for Http" #168

Closed
Masterchef365 opened this issue Feb 19, 2021 · 1 comment
Closed

Unable use send_file, "Invalid scheme for Http" #168

Masterchef365 opened this issue Feb 19, 2021 · 1 comment
Labels

Comments

@Masterchef365
Copy link

Having trouble getting files to send using send_file. Commit hash: 245f573
Example code:

// Log in to Discord using a bot token from the environment
let discord = Discord::from_bot_token(&env::var("DISCORD_TOKEN").expect("Expected token"))
    .expect("login failed");

// Establish and use a websocket connection
let (mut connection, _) = discord.connect().expect("connect failed");
println!("Ready.");
loop {
    match connection.recv_event() {
        Ok(Event::MessageCreate(message)) => {
            println!("{} says: {}", message.author.name, message.content);
            if message.content == "!test" {
                discord.send_file(
                    message.channel_id,
                    "This is a reply to the test.",
                    "This is a test text file".as_bytes(),
                    "test.txt",
                ).expect("Failed to send file");
            }
        }
        Ok(_) => {}
        Err(discord::Error::Closed(code, body)) => {
            println!("Gateway closed on us with code {:?}: {}", code, body);
            break;
        }
        Err(err) => println!("Receive error: {:?}", err),
    }
}

When I DM the bot !test, I get the following:

thread 'main' panicked at 'Failed to send file: Hyper(Io(Custom { kind: InvalidInput, error: "Invalid scheme for Http" }))'

Which suggests to me that TLS isn't being used... But I'm not sure. I tried to find where the hyper Client was being referenced, but didn't have much time. I'll try stepping through the code later tonight to see where the problem might be (and perhaps submit a PR if I find a fix) but I wanted to create an issue first.

@chxry
Copy link

chxry commented May 27, 2021

Have you managed to fix this issue. I have the same error using send_file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants