📁
KSoft.rs
  • KSoft.rs
  • Shared types
  • Images
    • Types
    • Endpoints
  • Bans
    • Types
    • Endpoints
  • Kumo
    • Types
    • Endpoints
  • Music
    • Types
    • Endpoints
  • Events
    • Types
    • Examples
Powered by GitBook
On this page
  • Get bans
  • Report an user
  • Check if user is banned
  • Get information about a ban
  • Delete a ban

Was this helpful?

  1. Bans

Endpoints

Get bans

async fn advanced_paginate(&self, page: u8, per_page: u8) -> HttpResult<BanList, BanError>

async fn paginate(&self) -> HttpResult<BanList, BanError>
//paginate() is an advanced_paginate() shortcut with default parameters (1, 12)
if let Ok(res) = client.bans.paginate().await {
    match res {
        Ok(bans) => {
            //do something with ban list
        },
        Err(why) => {
            //do something with the <BanError> struct
        }
    }
}

Report an user

async fn add<S: ToString>(&self,
      user_id: u64,
      reason: S,
      proof: S,
      moderator: Option<u64>,
      user_name: Option<String>,
      user_discriminator: Option<u16>,
      appeal_possible: Option<bool>)
    -> HttpResult<BanAdditionResponse, BanError>
if let Ok(res) = client.bans.add(23123123, 
"some reason",
"some proof",
None,
None,
Some("discriminator"),
None).await {
    match res {
        Ok(response) => {
            //Do something with the response
        },
        Err(why) => {
            //Domething with <BanError>
        }
    }
}

Check if user is banned

async fn check_ban(&self, user_id: u64) -> Result<BanCheckResponse>
if let Ok(ban) = client.bans.check_ban(12335454).await {
    //do something with the ban
}

Get information about a ban

async fn ban_info(&self, user_id: u64) -> HttpResult<BanInfoResponse, BanError
if let Ok(res) = client.bans.ban_info(1231231234124).await {
    match res {
        Ok(ban) => {
            //do something with ban info
        },
        Err(why) => {
            //do something with the <BanError> struct
        }
    }
}

Delete a ban

To use this method you must have BAN_MANAGER permission

async fn delete(&self, user_id: u64) -> HttpResult<BanDeletionResponse, BanError>
//or
async fn delete_forcing(&self, user_id: u64) -> HttpResult<BanDeletionResponse, BanError>
//to force the ban deletion
if let Ok(res) = client.bans.delete(1231231234124).await {
    match res {
        Ok(ban) => {
            //do something with ban info
        },
        Err(why) => {
            //do something with the <BanError> struct
        }
    }
}
PreviousTypesNextTypes

Last updated 4 years ago

Was this helpful?