Skip to content

Commit 59f40fd

Browse files
committed
actually revert changes
1 parent 4b1c006 commit 59f40fd

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

examples/e01_basic_ping_bot/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
name = "e01_basic_ping_bot"
33
version = "0.1.0"
44
authors = ["my name <[email protected]>"]
5-
edition.workspace = true
5+
edition = "2018"
66

77
[dependencies]
8-
serenity = { path = "../../", default-features = false, features = ["gateway", "model", "rustls_backend"] }
9-
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
8+
serenity = { path = "../../", default-features = false, features = ["client", "gateway", "rustls_backend", "model"] }
9+
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }

examples/e01_basic_ping_bot/src/main.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::env;
2+
13
use serenity::async_trait;
24
use serenity::model::channel::Message;
35
use serenity::model::gateway::Ready;
@@ -9,8 +11,8 @@ struct Handler;
911
impl EventHandler for Handler {
1012
// Set a handler for the `message` event. This is called whenever a new message is received.
1113
//
12-
// Event handlers are dispatched through a threadpool, and so multiple events can be dispatched
13-
// simultaneously.
14+
// Event handlers are dispatched through a threadpool, and so multiple events can be
15+
// dispatched simultaneously.
1416
async fn message(&self, ctx: Context, msg: Message) {
1517
if msg.content == "!ping" {
1618
// Sending a message can fail, due to a network error, an authentication error, or lack
@@ -35,8 +37,7 @@ impl EventHandler for Handler {
3537
#[tokio::main]
3638
async fn main() {
3739
// Configure the client with your Discord bot token in the environment.
38-
let token =
39-
Token::from_env("DISCORD_TOKEN").expect("Expected a valid token in the environment");
40+
let token = env::var("DISCORD_TOKEN").expect("Expected a token in the environment");
4041
// Set gateway intents, which decides what events the bot will be notified about
4142
let intents = GatewayIntents::GUILD_MESSAGES
4243
| GatewayIntents::DIRECT_MESSAGES
@@ -45,7 +46,7 @@ async fn main() {
4546
// Create a new instance of the Client, logging in as a bot. This will automatically prepend
4647
// your bot token with "Bot ", which is a requirement by Discord for bot users.
4748
let mut client =
48-
Client::builder(token, intents).event_handler(Handler).await.expect("Err creating client");
49+
Client::builder(&token, intents).event_handler(Handler).await.expect("Err creating client");
4950

5051
// Finally, start a single shard, and start listening to events.
5152
//
@@ -54,4 +55,4 @@ async fn main() {
5455
if let Err(why) = client.start().await {
5556
println!("Client error: {why:?}");
5657
}
57-
}
58+
}

0 commit comments

Comments
 (0)