Channel Parser Implementation

Parser implementations for disnake channel types.

Classes

class disnake_compass.impl.parser.channel.PartialMessageableParser(channel_type, int_parser=NOTHING)[source]

Bases: Parser[PartialMessageable]

Parser type with support for partial messageables.

Parameters:

Attributes

channel_type: ChannelType | None

The channel type to use for disnake.PartialMessageables created by this class.

This determines which operations are valid on the partial messageables.

int_parser: IntParser

The IntParser to use internally for this parser.

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

Methods

await dumps(argument, /)[source]

Dump a partial messageable into a string.

This uses the underlying int_parser.

Parameters:

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

await loads(argument, /)[source]

Load a partial messageable from a string.

This uses the underlying int_parser.

Parameters:

argument (str) –

The value that is to be loaded into a channel.

This always matches the channel type of the parser.

class disnake_compass.impl.parser.channel.ChannelParserBase(int_parser=None, *, allow_api_requests=True)[source]

Bases: Parser[_ChannelT]

Base class for synchronous parser types with support for channels.

Note

This class cannot be instantiated.

Parameters:
  • int_parser (IntParser | None) – 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 channel parser will also return compressed results.

Methods

await dumps(argument, /)[source]

Dump a channel into a string.

This uses the underlying int_parser.

Parameters:

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

await loads(argument, /)[source]

Load a channel from a string.

This uses the underlying int_parser.

Parameters:

argument (str) –

The value that is to be loaded into a channel.

This always matches the channel type of the parser.

Raises:
  • LookupError – A channel with the id stored in the argument could not be found.

  • TypeError – A channel with the id stored in the argument was found, but it was of an incorrect channel type.

Note

The following classes have the exact same attributes and methods as the ChannelParserBase base class, so their attributes and methods have been omitted.

class disnake_compass.impl.parser.channel.GuildChannelParser(parser_type, int_parser, allow_api_requests)[source]

Bases: ChannelParserBase[GuildChannel]

Parser type with support for guild channels.

Warning

This parser can make API requests.

Parameters:

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

class disnake_compass.impl.parser.channel.PrivateChannelParser(parser_type, int_parser, allow_api_requests)[source]

Bases: ChannelParserBase[PrivateChannel]

Parser type with support for private channels.

Warning

This parser can make API requests.

Parameters:

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

class disnake_compass.impl.parser.channel.DMChannelParser(parser_type, int_parser, allow_api_requests)[source]

Bases: ChannelParserBase[DMChannel]

Parser type with support for DM channels.

Warning

This parser can make API requests.

Parameters:

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

class disnake_compass.impl.parser.channel.GroupChannelParser(parser_type, int_parser, allow_api_requests)[source]

Bases: ChannelParserBase[GroupChannel]

Parser type with support for group channels.

Warning

This parser can make API requests.

Parameters:

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

class disnake_compass.impl.parser.channel.ForumChannelParser(parser_type, int_parser, allow_api_requests)[source]

Bases: ChannelParserBase[ForumChannel]

Parser type with support for forum channels.

Warning

This parser can make API requests.

Parameters:

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

class disnake_compass.impl.parser.channel.NewsChannelParser(parser_type, int_parser, allow_api_requests)[source]

Bases: ChannelParserBase[NewsChannel]

Parser type with support for news channels.

Warning

This parser can make API requests.

Parameters:

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

class disnake_compass.impl.parser.channel.VoiceChannelParser(parser_type, int_parser, allow_api_requests)[source]

Bases: ChannelParserBase[VoiceChannel]

Parser type with support for voice channels.

Warning

This parser can make API requests.

Parameters:

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

class disnake_compass.impl.parser.channel.StageChannelParser(parser_type, int_parser, allow_api_requests)[source]

Bases: ChannelParserBase[StageChannel]

Parser type with support for stage channels.

Warning

This parser can make API requests.

Parameters:

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

class disnake_compass.impl.parser.channel.TextChannelParser(parser_type, int_parser, allow_api_requests)[source]

Bases: ChannelParserBase[TextChannel]

Parser type with support for text channels.

Warning

This parser can make API requests.

Parameters:

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

class disnake_compass.impl.parser.channel.ThreadParser(parser_type, int_parser, allow_api_requests)[source]

Bases: ChannelParserBase[Thread]

Parser type with support for threads.

Warning

This parser can make API requests.

Parameters:

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

class disnake_compass.impl.parser.channel.CategoryParser(parser_type, int_parser, allow_api_requests)[source]

Bases: ChannelParserBase[CategoryChannel]

Parser type with support for categories.

Warning

This parser can make API requests.

Parameters:

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