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

Can't connect because of missing key "guild_positions" #178

Open
mraof opened this issue Nov 15, 2022 · 1 comment
Open

Can't connect because of missing key "guild_positions" #178

mraof opened this issue Nov 15, 2022 · 1 comment

Comments

@mraof
Copy link
Contributor

mraof commented Nov 15, 2022

When I call connect() it fails with Err Decode("Unexpected absent key", String("guild_positions"))

@rubenh2905
Copy link

i have same problem, with bot token anything is god but on user token same error

main.rs

use discord::Discord;
use discord::model::{Event};

#[tokio::main]
async fn main() {
    let token = "TOKEN";
    let discord = match Discord::from_user_token(token) {
        Ok(discord) => { discord }
        Err(err) => {
            eprintln!("Error 1: {:?}", err);
            return;
        }
    };
    let (mut connection, ready) = match discord.connect() {
        Ok((connection, ready)) => { (connection, ready) }
        Err(err) => {
            eprintln!("Error 2: {:?}", err);
            return;
        }
    };
    println!(
        "[Ready] {} is serving {} servers",
        ready.user.username,
        ready.servers.len()
    );
    loop {
        let event = match connection.recv_event() {
            Ok(event) => { event }
            Err(err) => {
                eprintln!("Error 3: {:?}", err);
                return;
            }
        };
        match event {
            Event::Ready(event) => {
                println!("[Ready] Version: {:?}", event.version);
            }
            Event::MessageCreate(event) => {
                println!("[Message:Create] {}\n{}", event.author.name, event.content);
            }
            Event::MessageUpdate { author, content, .. } => {
                let author = match author {
                    None => { continue; }
                    Some(author) => { author }
                };
                let content = match content {
                    None => { continue; }
                    Some(content) => { content }
                };
                println!("[Message:Update] {}\n{}", author.name, content);
            }
        }
    }
}

Cargo.toml

[package]
name = "DiscordBot"
version = "0.1.0"
edition = "2021"

[[bin]]
name = "discord_client"
path = "src/main.rs"

[dependencies]
discord = { git = "https://github.com/SpaceManiac/discord-rs" }
tokio = { version = "1.21.2", features = ["macros", "rt-multi-thread"] }

program output

Error 2: Decode("Unexpected absent key", String("guild_positions"))

some more info

> cargo -Vv
cargo 1.66.1 (ad779e08b 2023-01-10)                               
release: 1.66.1                                                   
commit-hash: ad779e08be893e57a9e17a810223a3e966f8c0d8             
commit-date: 2023-01-10                                           
host: x86_64-pc-windows-gnu                                       
libgit2: 1.5.0 (sys:0.16.0 vendored)                              
libcurl: 7.83.1-DEV (sys:0.4.55+curl-7.83.1 vendored ssl:Schannel)
os: Windows 10.0.19044 (Windows 10 Pro) [64-bit]

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

No branches or pull requests

2 participants