topgg-rs
A rust wrapper for the top.gg API that abides by their rate limit and even has webhook support.
How to use
In your cargo.toml
please put
[dependencies]
topgg-rs = "0.3.0"
Standard usage
#[tokio::main]
async fn main() {
c = topgg::Topgg::new(bot_id, topgg_token);
c.my_bot().await.unwrap();
c.bot(another_bot_id).await.unwrap();
c.user(a_user_id).await.unwrap();
c.my_votes().await.unrwap();
c.votes(another_bot_id).await.unrwap();
c.voted_for_me(user_id).await.unwrap();
c.voted(another_bot_id, user_id).await.unwrap();
c.get_bot_stats(another_bot_id).await.unwrap();
c.my_bot_stats().await.unwrap();
c.post_bot_stats(Some(server_count), None, None, None).await;
c.post_bot_stats(None, Some(shards), None, None).await;
c.post_bot_stats(Some(server_count), None, Some(shard_id_that_posted), None).await;
c.post_bot_stats(Some(server_count), None, None, Some(shard_count)).await;
}
Webhook support
If you want to use webhooks with this then here is an example
use futures::StreamExt;
#[tokio::main]
async fn main() {
let mut events = topgg::WebhookClient::start(3030, "a-very-secret-password".to_string());
while let Some(msg) = events.next().await {
println!("{:?}", msg)
}
}