Skip to content
This repository has been archived by the owner on Oct 25, 2019. It is now read-only.

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Romain Gautier committed Mar 27, 2017
1 parent ddf88d6 commit 82637a6
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
**/*.rs.bk
7 changes: 7 additions & 0 deletions Cargo.toml
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"
42 changes: 42 additions & 0 deletions src/main.rs
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)
}
}
}

0 comments on commit 82637a6

Please sign in to comment.