blob: 032804266ee1780ced8bb8a38449ea8e782a1fbc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
extern crate serenity;
use serenity::Client;
use std::env;
fn main() {
// Configure the client with your Discord bot token in the environment.
let token = env::var("DISCORD_TOKEN")
.expect("Expected a token in the environment");
// Logging in is essentially equivilant to logging in as a user.
//
// The primary difference is that by using `login_user`, the "Bot " string
// is not prefixed to the token.
//
// Additionally, the Client will now know that you are a user, and will
// disallow you from performing bot-only commands.
let mut client = Client::login_user(&token);
client.on_ready(|_context, ready| {
println!("{} is connected!", ready.user.name);
});
if let Err(why) = client.start() {
println!("Client error: {:?}", why);
}
}
|