> ## Documentation Index
> Fetch the complete documentation index at: https://docs.readmin.app/llms.txt
> Use this file to discover all available pages before exploring further.

# ReAdmin Ranking Module

> Learn how to use the Roblox ReAdmin Ranking Module for Group Management

## Overview

The **ReAdmin Ranking Module** enables you to interact with the [ReAdmin Ranking API](/settings/ranking-api) to manage Roblox group ranks, shout messages, and process join requests efficiently within your game. It simplifies communication with the ReAdmin Ranking API, allowing you to focus on game logic rather than API intricacies.

## Getting Started

Before getting started, ensure you have a valid [ReAdmin Ranking Key](/api-reference/api-keys) from the [ReAdmin dashboard](https://panel.readmin.app/). This key is required to authenticate requests.

**Installation:**

1. Locate the ReAdmin Ranking Module on Roblox:

   [ReAdmin Ranking Module (Asset ID: 104472617301635)](https://create.roblox.com/store/asset/104472617301635/ReAdmin-Ranking-Module)

2. Insert the module into your game (e.g., into **ReplicatedStorage**).

3. Require the module and initialize it using your **ReAdmin Ranking Key**.

```lua theme={null}
local apiKey = 'DO_NOT_SHARE_ReAdmin_Ranking_Key_Id_DO_NOT_SHARE=...'; 
local ranking = require(104472617301635)

local ReAdmin = ranking.new(apiKey)
```

> Note: It is recommended to use the require() call directly on the asset ID. This approach allows you to seamlessly receive updates to the module without manually re-importing it into your project.

## Usage and Examples

Once you have initialized the module, you have access to several methods for managing group ranks, join requests, shouts, and more.

## Retrieve Ranking Key Info

Get details about your ranking key and its configuration:

```lua theme={null}
local keyInfo = ReAdmin:getRankingKeyInfo()
print(keyInfo)
```

```json theme={null}
{
  "success": true,
  "keyInfo": {
    "_id": "655ad2a1afb59527556cb3b6",
    "groupId": "10792229",
    "id": "0234028d-3565-4832-9bdb-d7a3e32691d0",
    "key": false,
    "name": "Testing Key",
    "rankingEnabled": true,
    "allowedRanks": [
        {
        "name": "Example",
        "apiId": 1,
        "rank": 1,
        "id": 1
      }
    ],
    "enableShouting": true,
    "enableJoinRequestManagement": true,
    "enableExile": true,
    "created": "2023-11-20T03:29:37.736Z"
  }
}
```

## Ranking Users

Ranking Users
To rank a user in your group, use the rankUser method. Provide a valid Roblox user ID and a rank ID (1-255). The specified rank ID must be allowed by your ReAdmin Ranking Key configuration.

```lua theme={null}
ReAdmin:rankUser(1, 2) -- Ranks user with ID 1 to rank ID 2
```

## Exile Users

Exiling Users
To exile (remove) a user from your group, call the exileUser method:

```lua theme={null}
local response = ReAdmin:exileUser(1)
print(response)
```

Possible responses include:

```json theme={null}
{"success":true,"reason":"User has been exiled."}
```

```json theme={null}
{"success":false,"reason":"User not found."}
```

## Managing Join Requests

If your ranking key supports join request management, you can fetch pending join requests and accept or decline them.

```lua theme={null}
local joinRequests = ReAdmin:getJoinRequests()
print(joinRequests)
```

Exampe Response

```json theme={null}
{
  "success": true,
  "groupJoinRequests": [
    {
      "path": "groups/10792229/join-requests/27466614",
      "createTime": "2024-12-13T05:11:17.423Z",
      "user": "users/27466614"
    }
  ],
  "nextPageToken": ""
}

```

Each user field is something like "users/27466614". You need to parse it to extract the user ID from the string (e.g., by ParseJoinRequestToUserId).

Example Code for Handling Join Requests:

```lua theme={null}
local joinRequests = ReAdmin:getJoinRequests()
print(joinRequests)

for _, joinRequest in pairs(joinRequests.groupJoinRequests) do
    local joinRequestId = ReAdmin:ParseJoinRequestToUserId(joinRequest)
    
    -- Randomly decide to accept or decline:
    if math.random(0,1) == 0 then
        ReAdmin:acceptJoinRequest(joinRequestId)
    else
        ReAdmin:declineJoinRequest(joinRequestId)
    end
end
```

## Posting a Shout to the Group Wall

If allowed by your key, you can post a shout message to your Roblox group wall:

```lua theme={null}
ReAdmin:shout("Hello, world!")
```

Success reponse

```json theme={null}
{"success":true,"message":"Shout has been posted"}
```

## Common Error Responses

* **Unauthorized (401)**: If the `success` field is `false` with a reason like "Rank is not allowed", verify that the rank ID you are attempting to set is permitted by your ranking key's configuration.
* **Bad Request (400)**: Verify that the user exists and that you have the correct user ID.
* **Server Error (500)**: Check that the ReAdmin API is functioning correctly and that your requests are formatted properly.

## Conclusion

With the ReAdmin Ranking Module, managing group ranks, join requests, and group shouts becomes a straightforward process. By following this documentation and leveraging the provided methods, you can seamlessly integrate the ReAdmin Ranking API into your game workflow.
