Skip to content

members

roblox.members

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

Member (MemberRelationship)

Represents a group member.

Attributes:

Name Type Description
id int

The member's ID.

name str

The member's name.

display_name str

The member's display name.

role PartialRole

The member's role.

group BaseGroup

The member's group.

Source code in roblox/members.py
class Member(MemberRelationship):
    """
    Represents a group member.

    Attributes:
        id: The member's ID.
        name: The member's name.
        display_name: The member's display name.
        role: The member's role.
        group: The member's group.
    """

    def __init__(self, client: Client, data: dict, group: BaseGroup):
        self._client: Client = client

        self.id: int = data["user"]["userId"]
        self.name: str = data["user"]["username"]
        self.display_name: str = data["user"]["displayName"]

        super().__init__(client=self._client, user=self.id, group=group)

        self.role: PartialRole = PartialRole(client=self._client, data=data["role"])
        self.group: BaseGroup = group

    def __repr__(self):
        return f"<{self.__class__.__name__} id={self.id} name={self.name!r} role={self.role}>"

__init__(self, client: Client, data: dict, group: BaseGroup) special

Source code in roblox/members.py
def __init__(self, client: Client, data: dict, group: BaseGroup):
    self._client: Client = client

    self.id: int = data["user"]["userId"]
    self.name: str = data["user"]["username"]
    self.display_name: str = data["user"]["displayName"]

    super().__init__(client=self._client, user=self.id, group=group)

    self.role: PartialRole = PartialRole(client=self._client, data=data["role"])
    self.group: BaseGroup = group

__repr__(self) special

Source code in roblox/members.py
def __repr__(self):
    return f"<{self.__class__.__name__} id={self.id} name={self.name!r} role={self.role}>"

MemberRelationship (BaseUser)

Represents a relationship between a user and a group.

Attributes:

Name Type Description
group BaseGroup

The corresponding group.

Source code in roblox/members.py
class MemberRelationship(BaseUser):
    """
    Represents a relationship between a user and a group.

    Attributes:
        group: The corresponding group.
    """

    def __init__(self, client: Client, user: Union[BaseUser, int], group: Union[BaseGroup, int]):
        self._client: Client = client
        super().__init__(client=self._client, user_id=int(user))

        self.group: BaseGroup

        if isinstance(group, int):
            self.group = BaseGroup(client=self._client, group_id=group)
        else:
            self.group = group

    async def set_role(self, role: RoleOrRoleId):
        """
        Sets this member's role.

        Arguments:
            role: The new role this member should be assigned.
        """
        await self.group.set_role(self, role)

    async def set_rank(self, rank: int):
        """
        Sets this member's rank.

        Arguments:
            rank: The new rank this member should be assigned. Should be in the range of 0-255.
        """
        await self.group.set_rank(self, rank)

    async def kick(self):
        """
        Kicks this member from the group.
        """
        await self.group.kick_user(self)

__init__(self, client: Client, user: Union[BaseUser, int], group: Union[BaseGroup, int]) special

Source code in roblox/members.py
def __init__(self, client: Client, user: Union[BaseUser, int], group: Union[BaseGroup, int]):
    self._client: Client = client
    super().__init__(client=self._client, user_id=int(user))

    self.group: BaseGroup

    if isinstance(group, int):
        self.group = BaseGroup(client=self._client, group_id=group)
    else:
        self.group = group

kick(self) async

Kicks this member from the group.

Source code in roblox/members.py
async def kick(self):
    """
    Kicks this member from the group.
    """
    await self.group.kick_user(self)

set_rank(self, rank: int) async

Sets this member's rank.

Parameters:

Name Type Description Default
rank int

The new rank this member should be assigned. Should be in the range of 0-255.

required
Source code in roblox/members.py
async def set_rank(self, rank: int):
    """
    Sets this member's rank.

    Arguments:
        rank: The new rank this member should be assigned. Should be in the range of 0-255.
    """
    await self.group.set_rank(self, rank)

set_role(self, role: RoleOrRoleId) async

Sets this member's role.

Parameters:

Name Type Description Default
role RoleOrRoleId

The new role this member should be assigned.

required
Source code in roblox/members.py
async def set_role(self, role: RoleOrRoleId):
    """
    Sets this member's role.

    Arguments:
        role: The new role this member should be assigned.
    """
    await self.group.set_role(self, role)