Users

User system is one of the main parts of GD Server API. gd.py provides convenient interface for simplifying interaction with them via modern pythonic code.

Here is a quick example of interacting with users:

client = gd.Client()

user = await client.get_user(71)
# <User account_id=71 id=16 name='RobTop' ...>

for comment in await user.get_comment_history(pages=range(20)):
    print(comment.id, comment.rating, comment.body)

User

class gd.AbstractUser(*, client: gd.client.Client, **options)[source]

Class that represents an Abstract Geometry Dash User. This class is derived from AbstractEntity.

name

String representing name of the user.

Type

str

account_id

Account ID of the user.

Type

int

is_registered()bool[source]

bool: Indicates whether user is registered or not.

as_user() → gd.abstractuser.AbstractUser[source]

Returns AbstractUser object.

This is used mainly in subclasses.

Returns

Abstract User from given object.

Return type

AbstractUser

await to_user() → gd.user.User[source]

This function is a coroutine.

Convert self to User object.

Returns

A user object corresponding to the abstract one.

Return type

User

await update()None[source]

This function is a coroutine.

Update self.

await send(subject: str, body: str) → Optional[gd.message.Message][source]

This function is a coroutine.

Send the message to self. Requires logged client.

Parameters
  • subject (str) – The subject of the message.

  • body (str) – The body of the message.

  • from_client (Client) – A logged in client to send a message from. If None, defaults to a client attached to this user.

Raises

MissingAccess – Failed to send a message.

Returns

Sent message.

Return type

Optional[Message]

await block()None[source]

This function is a coroutine.

Block a user. Requires logged in client.

Raises

MissingAccess – Failed to block a user.

await unblock()None[source]

This function is a coroutine.

Unblock a user. Requires logged in client.

Raises

MissingAccess – Failed to unblock a user.

await unfriend()None[source]

This function is a coroutine.

Try to unfriend a user. Requires logged in client.

Raises

MissingAccess – Failed to unfriend a user.

await send_friend_request(message: str = '') → Optional[gd.friend_request.FriendRequest][source]

This function is a coroutine.

Send a friend request to a user.

Note

This function does not raise any error if request was already sent.

Parameters

message (str) – A message to attach to a request.

Raises

MissingAccess – Failed to send a friend request to user.

Returns

Sent friend request.

Return type

Optional[FriendRequest]

await get_levels_on_page(page: int = 0, *, exclude: Tuple[Type[BaseException]] = (<class 'gd.errors.NothingFound'>, )) → List[gd.level.Level][source]

This function is a coroutine.

Fetches user’s levels on a given page.

This function is equivalent to calling:

await self.client.search_levels_on_page(
    page=page, filters=gd.Filters.setup_by_user(),
    user=self, exclude=exclude
)
# 'self' is an AbstractUser instance here.
Parameters
  • page (int) – Page to look for levels at.

  • exclude (Tuple[Type[BaseException]]) – Exceptions to ignore. By default includes only NothingFound.

Returns

All levels found. Can be an empty list.

Return type

List[Level]

await get_levels(pages: Iterable[int] = range(0, 10)) → List[gd.level.Level][source]

This function is a coroutine.

Gets levels on specified pages.

This is equivalent to calling:

return await self.client.search_levels(
    pages=pages, filters=gd.Filters.setup_by_user(), user=self
)
# where 'self' is an AbstractUser instance.
Parameters

pages (Sequence[int]) – Pages to look at, represented as a finite sequence, so iterations can be performed.

Returns

List of levels found. Can be an empty list.

Return type

List[Level]

await get_page_comments(page: int = 0, exclude: Tuple[Type[BaseException]] = (<class 'gd.errors.NothingFound'>, )) → List[gd.comment.Comment][source]

This function is a coroutine.

Gets user’s profile comments on a specific page.

This is equivalent to:

await self.retrieve_page_comments('profile', page, exclude=exclude)
await get_page_comment_history(strategy: Union[int, str, gd.utils.enums.CommentStrategy] = 0, page: int = 0, exclude: Tuple[Type[BaseException]] = (<class 'gd.errors.NothingFound'>, )) → List[gd.comment.Comment][source]

This function is a coroutine.

Retrieves user’s level comments. (history)

Equivalent to calling:

await self.retrieve_page_comments('profile', page, strategy=strategy, exclude=exclude)
await get_comments(pages: Optional[Iterable[int]] = range(0, 10)) → List[gd.comment.Comment][source]

This function is a coroutine.

Gets user’s profile comments on specific pages.

This is equivalent to the following:

await self.retrieve_comments('profile', pages)
await get_comment_history(strategy: Union[int, str, gd.utils.enums.CommentStrategy] = 0, pages: Optional[Iterable[int]] = range(0, 10)) → List[gd.comment.Comment][source]

This function is a coroutine.

Gets user’s level (history) comments on specific pages.

This is equivalent to the following:

await self.retrieve_comments('level', pages, strategy=strategy)
await retrieve_page_comments(type: str = 'profile', page: int = 0, *, strategy: Union[int, str, gd.utils.enums.CommentStrategy] = 0, exclude: Tuple[Type[BaseException]] = (<class 'gd.errors.NothingFound'>, )) → List[gd.comment.Comment][source]

This function is a coroutine.

Utilizes getting comments. This is used in two other methods, User.get_page_comments() and User.get_page_comment_history().

Parameters
  • type (str) – Type of comments to retrieve. Either ‘profile’ or ‘level’. Defaults to ‘profile’.

  • page (int) – Page to look comments at.

  • exclude (Tuple[Type[BaseException]]) – Exceptions to ignore. By default includes only NothingFound.

  • strategy (Union[int, str, CommentStrategy]) – A strategy to apply when searching.

Returns

List of all comments retrieved, if comments were found.

Return type

List[Comment]

Raises

NothingFound – No comments were found.

await retrieve_comments(type: str = 'profile', pages: Optional[Iterable[int]] = range(0, 10), strategy: Union[int, str, gd.utils.enums.CommentStrategy] = 0) → List[gd.comment.Comment][source]

This function is a coroutine.

Utilizes getting comments on specified pages.

Parameters
  • type (str) – Type of comments to retrieve. Either ‘profile’ or ‘level’. Defaults to ‘profile’.

  • pages (Sequence[int]) – Pages to look at, represented as a finite sequence, so iterations can be performed.

  • strategy (Union[int, str, CommentStrategy]) – A strategy to apply when searching.

Returns

List of comments found. Can be an empty list.

Return type

List[Comment]

class gd.LevelRecord(*, client: gd.client.Client, **options)[source]

Class that represents Geometry Dash User’s Level Record. This class is derived from AbstractUser.

await update()None[source]

This function is a coroutine.

Update self.

level_id

An integer representing ID of the level the record was retrieved from.

Type

int

percentage

Percentage of the record.

Type

int

coins

Amount of coins collected.

Type

int

timestamp

Human-readable string representation of a timestamp.

Type

str

place

User’s place in leaderboard. 0 if not set.

Type

int

class gd.UserStats(*, client: gd.client.Client, **options)[source]

Class that extends AbstractUser, adding user’s statistics to it.

stars

Amount of stars the user has.

Type

int

demons

Amount of demons the user has beaten.

Type

int

cp

Amount of Creator Points the user has.

Type

int

diamonds

Amount of diamonds the user has.

Type

int

coins

Number of coins the user has.

Type

int

user_coins

Amount of User Coins user has.

Type

int

place

User’s place in leaderboard. 0 if not set.

Type

int

has_cp()bool[source]

bool: Indicates if a user has Creator Points.

set_place(place: int = 0)None[source]

Set the self.place to place argument.

await update()None[source]

This function is a coroutine.

Update self.

class gd.User(*, client: gd.client.Client, **options)[source]

Class that represents a Geometry Dash User. This class is derived from UserStats.

role

A status level of the user.

Type

StatusLevel

rank

A global rank of the user. None if the user is not on the leaderboard.

Type

Optional[int]

youtube

A youtube name of the user.

Type

str

A link to the user’s youtube channel.

Type

str

twitter

A twitter name of the user.

Type

str

A link to the user’s twitter page.

Type

str

twitch

A twitch name of the user.

Type

str

A link to the user’s twitch channel.

Type

str

message_policy

A type indicating user’s message inbox policy.

Type

MessagePolicyType

friend_request_policy

A type indicating user’s friend requests policy.

Type

FriendRequestPolicyType

comment_policy

A type indicating user’s comment history policy.

Type

CommentPolicyType

icon_set

An iconset of the user.

Type

IconSet

is_mod(elder: Optional[str] = None)bool[source]

bool: Indicates if a user is Geometry Dash (Elder) Moderator. For instance, RobTop is an Elder Moderator, that means: robtop.is_mod() -> True and robtop.is_mod('elder') -> True.

await update()None[source]

This function is a coroutine.

Update the user’s statistics and other parameters.

gd.py also provides interface to users’ icons and colors:

nekit = await client.get_user(5509312)
# <User account_id=5509312 id=17876467 name='nekitdev' ...>

Icon Set and Color

class gd.IconSet(*, client: gd.client.Client = None, **options)[source]

Class that represents an Icon Set.

id

ID of the icon set, based on colors and main icon.

Type

int

main

ID of the main icon of the iconset. (see IconSet.main_type)

Type

int

color_1

A first color of the iconset.

Type

Color

color_2

A second color of the iconset.

Type

Color

main_type

A type of the main icon of the iconset.

Type

IconType

cube

Cube ID of the iconset.

Type

int

ship

Ship ID of the iconset.

Type

int

ball

Ball ID of the iconset.

Type

int

ufo

UFO ID of the iconset.

Type

int

wave

Wave ID of the iconset.

Type

int

robot

Robot ID of the iconset.

Type

int

spider

Spider ID of the iconset.

Type

int

explosion

Explosion ID of the iconset.

Type

int

has_glow_outline()bool[source]

bool: Indicates whether an iconset has glow outline.

get_colors() → Tuple[gd.colors.Color, gd.colors.Color][source]

Tuple[Color, Color]: A shorthand for color_1 and color_2.

await generate(type: Optional[Union[int, str, gd.utils.enums.IconType]] = None, as_image: bool = False) → Union[bytes, PIL.Image.Image][source]

This function is a coroutine.

Generate an image of an icon.

Parameters
  • type (Optional[Union[int, str, IconType]]) – Type of an icon to generate. If not given or "main", picks current main icon.

  • as_image (bool) – Whether to return an image or bytes of an image.

Returns

Bytes or an image, based on as_image.

Return type

Union[bytes, PIL.Image.Image]

await generate_many(*types: Iterable[Union[int, str, gd.utils.enums.IconType]], as_image: bool = False) → Union[List[bytes], List[PIL.Image.Image]][source]

This function is a coroutine.

Generate images of icons.

Parameters
  • *types (Iterable[Optional[Union[int, str, IconType]]]) – Types of icons to generate. If "main" is given, picks current main icon.

  • as_image (bool) – Whether to return images or bytes of images.

Returns

List of bytes or of images, based on as_image.

Return type

Union[List[bytes], List[PIL.Image.Image]]

await generate_image(*types: Iterable[Union[int, str, gd.utils.enums.IconType]], as_image: bool = False) → Union[bytes, PIL.Image.Image][source]

This function is a coroutine.

Generate images of icons and connect them into one image.

Parameters
  • *types (Iterable[Optional[Union[int, str, IconType]]]) – Types of icons to generate. If "main" is given, picks current main icon.

  • as_image (bool) – Whether to return an image or bytes of an image.

Returns

Bytes or an image, based on as_image.

Return type

Union[bytes, PIL.Image.Image]

await generate_full(as_image: bool = False) → Union[bytes, PIL.Image.Image][source]

This function is a coroutine.

Generate an image of the full icon set.

Parameters

as_image (bool) – Whether to return an image or bytes of an image.

Returns

Bytes or an image, based on as_image.

Return type

Union[bytes, PIL.Image.Image]

class gd.Color(value: int = 0)[source]

Represents a Color. This class is similar to a (red, green, blue) tuple.

There is an alias for this called Colour.

value

The raw integer colour value.

Type

int

index

Returns index that represents position of the colour in colors. None if the colour is not present in colors.

Type

Optional[int]

r

Returns the red component of the colour.

Type

int

g

Returns the green component of the colour.

Type

int

b

Returns the blue component of the colour.

Type

int

to_hex()str[source]

str: Returns the colour in hex format.

to_rgb() → Tuple[int, int, int][source]

Tuple[int, int, int]: Returns an (r, g, b) tuple representing the colour.

to_rgba() → Tuple[int, int, int, int][source]

Tuple[int, int, int, int]: Same as Color.to_rgb(), but contains alpha component (always 255).

classmethod from_rgb(r: int, g: int, b: int) → gd.colors.Color[source]

Constructs a Color from an RGB tuple.

classmethod from_hsv(h: float, s: float, v: float) → gd.colors.Color[source]

Constructs a Color from an HSV (HSB) tuple.