serenity-rs / serenity

A Rust library for the Discord API.
https://discord.gg/serenity-rs
ISC License
4.65k stars 571 forks source link

Serenity won't accept Discord Token no matter what #2912

Closed luigiistcrazy closed 1 month ago

luigiistcrazy commented 1 month ago

I might be stupid but I can't figure out why cargo run is always returning Expected a token in the environment: NotPresent.

Cargo.toml

[package]
name = "e01_basic_ping_bot"
version = "0.1.0"
authors = ["my name <my@email.address>"]
edition = "2018"

[dependencies]
tokio = { version = "1.21.2", features = ["macros", "rt-multi-thread"] }

[dependencies.serenity]
default-features = false
features = ["client", "gateway", "rustls_backend", "model"]
version = "0.12"

main.rs

Screenshot from 2024-07-01 18-32-22

jamesbt365 commented 1 month ago

You really should look in the documentation of std::env::var and read up on how environment variables work, you are looking for an environment variable with the name set to your token, not the actual value of the token.