Guild Parser Implementation

Parser implementations for disnake.Guild type.

Classes

class disnake_compass.impl.parser.guild.GuildParser(int_parser=NOTHING, *, allow_api_requests=True)[source]

Bases: Parser[Guild]

Parser type with support for guilds.

Warning

This parser can make API requests.

Parameters:
  • int_parser (IntParser) – The IntParser to use internally for this parser.

  • allow_api_requests (bool) – Whether or not to allow this parser to make API requests.

Attributes

allow_api_requests: bool

Whether or not to allow this parser to make API requests.

Parsers will always try getting a result from cache first.

int_parser: IntParser

The IntParser to use internally for this parser.

Since the default integer parser uses base-36 to “compress” numbers, the default guild parser will also return compressed results.

Methods

await dumps(argument)[source]

Dump a guild into a string.

This uses the underlying int_parser.

Parameters:

argument (Guild) – The value that is to be dumped.

await loads(argument, /)[source]

Load a guild from a string.

This uses the underlying int_parser.

Parameters:

argument (str) – The value that is to be loaded into a guild.

Raises:

LookupError – A guild with the id stored in the argument could not be found.

class disnake_compass.impl.parser.guild.InviteParser(*, with_counts=True, with_expiration=True, guild_scheduled_event_id=None)[source]

Bases: Parser[Invite]

Parser type with support for guilds.

Warning

This parser can make API requests.

Parameters:
  • with_counts (bool) – Whether to include count information in the invite.

  • with_expiration (bool) – Whether to include the expiration date of the invite.

  • guild_scheduled_event_id (int) –

    The ID of the scheduled event to include in the invite.

    If not provided, defaults to the event parameter in the URL if it exists, or the ID of the scheduled event contained in the provided invite object.

Attributes

guild_scheduled_event_id: int | None

The ID of the scheduled event to include in the invite.

with_counts: bool

Whether to include the number of times an invite was used.

with_expiration: bool

Whether to include when the invite expires.

Methods

await dumps(argument, /)[source]

Dump a guild invite into a string.

This uses the underlying int_parser.

Parameters:

argument (Invite) – The value that is to be dumped.

await loads(argument)[source]

Load a guild invite from a string.

This uses the underlying int_parser.

This method first tries to get the invite from cache. If this fails, it will try to fetch the invite instead.

Warning

This method can make API requests.

Parameters:

argument (str) – The value that is to be loaded into a guild invite.

class disnake_compass.impl.parser.guild.RoleParser(int_parser=NOTHING, *, allow_api_requests=True)[source]

Bases: Parser[Role]

Parser type with support for roles.

Warning

This parser can make API requests.

Parameters:
  • int_parser (IntParser) – The IntParser to use internally for this parser.

  • allow_api_requests (bool) – Whether or not to allow this parser to make API requests.

Attributes

allow_api_requests: bool

Whether or not to allow this parser to make API requests.

Parsers will always try getting a result from cache first.

int_parser: IntParser

The IntParser to use internally for this parser.

Since the default integer parser uses base-36 to “compress” numbers, the default guild parser will also return compressed results.

Methods

await dumps(argument)[source]

Dump a role into a string.

This uses the underlying int_parser.

Parameters:

argument (Role) – The value that is to be dumped.

await loads(argument)[source]

Load a role from a string.

This uses the underlying int_parser.

Parameters:

argument (str) – The value that is to be loaded into a role.

Raises:

LookupError – A role with the id stored in the argument could not be found.