Crates.io | railgun |
lib.rs | railgun |
version | 0.1.2 |
source | src |
created_at | 2019-12-27 21:33:51.585569 |
updated_at | 2019-12-27 22:01:18.794864 |
description | A Discord API library written in Rust supporting native async/await. |
homepage | |
repository | https://github.com/mental32/railgun |
max_upload_size | |
id | 192771 |
size | 11,554 |
Was bored. Started messing around with native async/await in Rust, wanted to test it out whilst writing a discord library.
Disclaimer! The examples shown below are what the library is aiming to eventually look like.
use {
std::{env, io},
railgun::{Client, register}
}
#[railgun::event(on = "MESSAGE_CREATE")]
async fn on_message(client: &Client, message: Message) -> Option<railgun::Error> {
println!("{:?}", message);
if message.content.starts_with("?ping") {
client.send(&message.channel, "Pong!").await?;
}
None
}
#[tokio::main]
async fn main() {
Client::default()
.mount(register![on_message])
.run(env::var("DISCORD_TOKEN")).await
.expect("Could not start discord client.");
}