pylav.core package

Submodules

pylav.core.bot_overrides module

async pylav.core.bot_overrides.get_context(self, message, /, *, cls=<class 'pylav.core.context.PyLavContext'>)[source]

Get the context for a command invocation.

async pylav.core.bot_overrides.process_commands(self, message, /)[source]

Same as base method, but dispatches an additional event for cogs which want to handle normal messages differently to command messages, without the overhead of additional get_context calls per cog.

pylav.core.client module

pylav.core.context module

class pylav.core.context.PyLavContext(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, subcommand_passed=None, command_failed=False, current_parameter=None, current_argument=None, interaction=None)[source]

Bases: Context

author

Union[User, Member]: Returns the author associated with this context’s command. Shorthand for Message.author

bot
channel

Returns the channel associated with this context’s command. Shorthand for Message.channel.

Type:

Union[abc.Messageable]

client
property cog

Returns the cog associated with this context’s command. None if it does not exist

Type:

Optional[Cog]

async connect_player(channel=None, self_deaf=None)[source]

Connect player

async construct_embed(*, embed=None, colour=None, color=None, title=None, embed_type='rich', url=None, description=None, timestamp=None, author_name=None, author_url=None, thumbnail=None, footer=None, footer_url=None, messageable=None)[source]

Construct embed

dispatch_command(message, command, author, args, prefix=None)[source]

Dispatch command

async classmethod from_interaction(interaction, /)[source]

Creates a context from a discord.Interaction. This only works on application command based interactions, such as slash commands or context menus.

On slash command based interactions this creates a synthetic Message that points to an ephemeral message that the command invoker has executed. This means that Context.author returns the member that invoked the command.

In a message context menu based interaction, the Context.message attribute is the message that the command is being executed on. This means that Context.author returns the author of the message being targetted. To get the member that invoked the command then discord.Interaction.user should be used instead.

Added in version 2.0.

Parameters:

interaction (discord.Interaction) – The interaction to create a context with.

Raises:
  • ValueError – The interaction does not have a valid command.

  • TypeError – The interaction client is not derived from Bot or AutoShardedBot.

guild

Returns the guild associated with this context’s command. None if not available

Type:

Optional[Guild]

interaction
property original_ctx_or_interaction

Get original ctx or interaction

property player

Get player

async send_interactive(messages, box_lang=None, timeout=15, embed=False)[source]

Send multiple messages interactively.

The user will be prompted for whether or not they would like to view the next message, one at a time. They will also be notified of how many messages are remaining on each prompt.

Parameters:
  • messages (iterable of str) – The messages to send.

  • box_lang (str) – If specified, each message will be contained within a codeblock of this language.

  • timeout (int) – How long the user has to respond to the prompt before it times out. After timing out, the bot deletes its prompt message.

  • embed (bool) – Whether or not to send the messages as embeds.

Module contents