RankGun Python Package
Installation
To install the RankGun package, run the following command:
pip install rankgun
After installing RankGun, you will be able to use its API client to interact with the RankGun API.
API Client
The RankGun class is the main API client for the RankGun API. It takes two arguments: api_token
& workspace_id
.
Which are required for authentication with the RankGun API.
Methods
The RankGun
class provides the following methods to interact with the RankGun API:
class RankGun:
"""A client for the RankGun API."""
def __init__(self, api_token, workspace_id):
self.api_key = api_token
self.workspace_id = workspace_id
RequestsSession.headers.update(
{"api-token": api_token, "Content-Type": "application/json"}
)
promote()
This method promotes a user's rank by +1.
async def promote(self, username=None, User_Id=None):
"""Promote a user. +1 rank"""
endpoint = "/ranking/promote"
params = {"workspace_id": self.workspace_id}
if username is not None:
params["username"] = username
elif User_Id is not None:
params["user_id"] = User_Id
return await self._post(endpoint, params=params)
demote()
This method demotes a user's rank by - 1.
async def demote(self, username=None, user_id=None):
"""
Demotes a user. -1 Rank
"""
data = {"workspace_id": self.workspace_id}
if username is not None:
data["username"] = username
elif user_id is not None:
data["user_id"] = user_id
return request("POST", "/roblox/demote", data)
set_rank()
This method sets the rank of a user to a specific value.
async def set_rank(self, rank, username=None, user_id=None):
"""
Sets rank of a user
"""
data = {"workspace_id": self.workspace_id, "rank": rank}
if username is not None:
data["username"] = username
elif user_id is not None:
data["user_id"] = user_id
return request("POST", "/roblox/set-rank", data)
exile()
This method removes a player from a group.
async def exile(self, username=None, user_id=None):
"""
Exiles a user
"""
data = {"workspace_id": self.workspace_id}
if username is not None:
data["username"] = username
elif user_id is not None:
data["user_id"] = user_id
shout()
This method updates the group shout.
async def shout(self, shout_text):
"""
Updates the shout of a group
"""
return request(
"POST",
"/roblox/shout",
{"shout_text": shout_text, "workspace_id": self.workspace_id},
)
Examples
Please check out an example (opens in a new tab) from our RankGun Package repo.
Contributions
Feel free to push any contributions (opens in a new tab) to the package.