Skip to content

roles

This module contains classes intended to parse and deal with data from Roblox group role endpoints.

Role

Bases: BaseRole

Represents a Roblox group's role.

Attributes:

Name Type Description
id int

The role's ID.

group Optional[BaseGroup]

The group that this role is a part of.

name str

The role's name.

description Optional[str]

The role's description.

rank int

The rank, from 0-255, of this role.

member_count Optional[int]

How many members exist with this role.

Source code in roblox/roles.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
class Role(BaseRole):
    """
    Represents a Roblox group's role.

    Attributes:
        id: The role's ID.
        group: The group that this role is a part of.
        name: The role's name.
        description: The role's description.
        rank: The rank, from 0-255, of this role.
        member_count: How many members exist with this role.
    """

    def __init__(self, client: Client, data: dict, group: BaseGroup = None):
        """
        Arguments:
            client: The Client object.
            data: The raw role data.
            group: The parent group.
        """
        self._client: Client = client

        self.id: int = data["id"]
        super().__init__(client=self._client, role_id=self.id)

        self.group: Optional[BaseGroup] = group
        self.name: str = data["name"]
        self.description: Optional[str] = data.get("description")
        self.rank: int = data["rank"]
        self.member_count: Optional[int] = data.get("memberCount")

    def get_members(self, page_size: int = 10, sort_order: SortOrder = SortOrder.Ascending,
                    max_items: int = None) -> PageIterator:
        """
        Gets all members with this role.

        Arguments:
            page_size: How many users should be returned for each page.
            sort_order: Order in which data should be grabbed.
            max_items: The maximum items to return when looping through this object.

        Returns:
            A PageIterator containing all members with this role.
        """
        return PageIterator(
            client=self._client,
            url=self._client.url_generator.get_url("groups", f"v1/groups/{self.group.id}/roles/{self.id}/users"),
            page_size=page_size,
            sort_order=sort_order,
            max_items=max_items,
            handler=lambda client, data: PartialUser(client=client, data=data)
        )

__init__(client, data, group=None)

Parameters:

Name Type Description Default
client Client

The Client object.

required
data dict

The raw role data.

required
group BaseGroup

The parent group.

None
Source code in roblox/roles.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
def __init__(self, client: Client, data: dict, group: BaseGroup = None):
    """
    Arguments:
        client: The Client object.
        data: The raw role data.
        group: The parent group.
    """
    self._client: Client = client

    self.id: int = data["id"]
    super().__init__(client=self._client, role_id=self.id)

    self.group: Optional[BaseGroup] = group
    self.name: str = data["name"]
    self.description: Optional[str] = data.get("description")
    self.rank: int = data["rank"]
    self.member_count: Optional[int] = data.get("memberCount")

get_members(page_size=10, sort_order=SortOrder.Ascending, max_items=None)

Gets all members with this role.

Parameters:

Name Type Description Default
page_size int

How many users should be returned for each page.

10
sort_order SortOrder

Order in which data should be grabbed.

Ascending
max_items int

The maximum items to return when looping through this object.

None

Returns:

Type Description
PageIterator

A PageIterator containing all members with this role.

Source code in roblox/roles.py
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
def get_members(self, page_size: int = 10, sort_order: SortOrder = SortOrder.Ascending,
                max_items: int = None) -> PageIterator:
    """
    Gets all members with this role.

    Arguments:
        page_size: How many users should be returned for each page.
        sort_order: Order in which data should be grabbed.
        max_items: The maximum items to return when looping through this object.

    Returns:
        A PageIterator containing all members with this role.
    """
    return PageIterator(
        client=self._client,
        url=self._client.url_generator.get_url("groups", f"v1/groups/{self.group.id}/roles/{self.id}/users"),
        page_size=page_size,
        sort_order=sort_order,
        max_items=max_items,
        handler=lambda client, data: PartialUser(client=client, data=data)
    )