This repository has been archived by the owner on Oct 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Romain Gautier
committed
Mar 27, 2017
1 parent
ddf88d6
commit 82637a6
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
target/ | ||
**/*.rs.bk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "rom-discord-bot" | ||
version = "0.1.0" | ||
authors = ["Romain Gautier <[email protected]>"] | ||
|
||
[dependencies] | ||
discord = "^0.8.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//client id: 295890698417340417 | ||
//client secret: eeX4u7GhSXAvt4CquizWb_--5sY41oQP | ||
|
||
//https://discordapp.com/oauth2/authorize?&client_id=295890698417340417&scope=bot&permissions=0 | ||
|
||
extern crate discord; | ||
|
||
use discord::Discord; | ||
use discord::model::Event; | ||
|
||
fn main() { | ||
|
||
let token_bot = "Mjk1ODkwNjk4NDE3MzQwNDE3.C7qTWA.uNinGhRhSMj3sun83Ke_uIF4kjw"; | ||
|
||
let discord = Discord::from_bot_token(&token_bot).expect("Unable to make bot from token."); | ||
|
||
|
||
let (mut connection, _) = discord.connect().expect("Unable to connect."); | ||
|
||
println!("Ready."); | ||
|
||
|
||
loop { | ||
|
||
match connection.recv_event() { | ||
Ok(Event::MessageCreate(message)) => { | ||
println!("{} says: {}", message.author.name, message.content); | ||
|
||
if message.content == "!quit" { | ||
println!("Quitting"); | ||
break | ||
} | ||
} | ||
Ok(_) => { } | ||
Err(discord::Error::Closed(code, body)) => { | ||
println!("Gateway closed on us with code {:?}: {}", code, body); | ||
break | ||
} | ||
Err(err) => println!("Received error: {:?}", err) | ||
} | ||
} | ||
} |