Struct topgg::Topgg[][src]

pub struct Topgg { /* fields omitted */ }

This is the top.gg API client. It houses the functions needed to interact with their API.

Implementations

impl Topgg[src]

pub fn new(bot_id: u64, token: String) -> Topgg[src]

Returns a new client.

Arguments

  • bot_id - The ID of your bot
  • token - The top.gg token for that (or another valid) bot

Examples

let client = topgg::Topgg::new(bot_id, token);
// Do stuff with the client
let votes = client.votes().await.unwrap();

pub async fn my_bot(&self) -> Option<Bot>[src]

A shortcut for getting the botinfo for your own bot.

Examples

let bot_info = client.my_bot().await.unwrap();

pub async fn bot(&self, bot_id: u64) -> Option<Bot>[src]

Gets the info for a bot given an ID. To get the info for your own bot client.my_bot() can be used as a shortcut.

Examples

let bot_info = lient.bot(668701133069352961).await.unwrap();

pub async fn user(&self, user_id: u64) -> Option<User>[src]

Gets the info for a user.

Examples

client.user(195512978634833920).await.unwrap();

pub async fn my_votes(&self) -> Option<Vec<u64>>[src]

A shortcut for getting the votes for the bot that created the client.

Examples

let votes = client.my_votes().await.unwrap();

pub async fn votes(&self, bot_id: u64) -> Option<Vec<u64>>[src]

Gets the user IDs of all the users that have voted on the bot_id.

Examples

client.votes(668701133069352961).await.unwrap();

pub async fn voted_for_me(&self, user_id: u64) -> Option<bool>[src]

A shortcut for checking if a user has voted for your own bot.

Examples

let voted = client.voted_for_me(195512978634833920).await.unwrap();

pub async fn voted(&self, bot_id: u64, user_id: u64) -> Option<bool>[src]

Checks if a user has voted for the bot or not. Returns true if they have, false if they have not.

Examples

let voted = client.voted(668701133069352961, 195512978634833920)
    .await
    .unwrap();

pub async fn my_bot_stats(&self) -> Option<BotStats>[src]

A shortcut for getting the bot stats of the bot that created the client.

Examples

let stats = client.my_bot_stats().await.unwrap();

pub async fn get_bot_stats(&self, bot_id: u64) -> Option<BotStats>[src]

Gets the 'stats' of the bot, this includes the server count, shard count, and shards (servers per shard).

Examples

client.get_bot_stats(Some(668701133069352961)).await.unwrap();

pub async fn post_bot_stats(
    &self,
    server_count: Option<u32>,
    shards: Option<Vec<u32>>,
    shard_id: Option<u32>,
    shard_count: Option<u32>
) -> Result<Response, Error>
[src]

This posts the stats for your bot. Useful if you want to update the server count on your top.gg bot page. You can omit from having a server_count if you use shards where it is a Vec of the number of servers per shard. shard_id is only applicable if you use sever_count and it tells top.gg the number of servers for that indexed shard.

Examples

client.post_bot_stats(None, Some(vec![142, 532, 304]), None, None).await;
client.post_bot_stats(Some(142), None, Some(0), None).await;
client.post_bot_stats(Some(978), None, None, Some(3)).await;

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,