interactions

class DeleteMessageButton(*, style=('secondary', 2), label='Delete', **kwargs)[source]

Bases: Button

A button that can be added to a view to delete the message containing the view on click.

This button itself carries out no interaction checks, these should be done by the parent view.

See pydis_core.utils.interactions.ViewWithUserAndRoleCheck for a view that implements basic checks.

Parameters:
  • style (ButtonStyle) – The style of the button, set to ButtonStyle.secondary if not specified.

  • label (str) – The label of the button, set to “Delete” if not specified.

__init__(*, style=('secondary', 2), label='Delete', **kwargs)[source]
async callback(interaction)[source]

Delete the original message on button click.

Return type:

None

class ViewWithUserAndRoleCheck(*, allowed_users, allowed_roles, timeout=180.0, message=None)[source]

Bases: View

A view that allows the original invoker and moderators to interact with it.

Parameters:
  • allowed_users (Sequence[int]) – A sequence of user’s ids who are allowed to interact with the view.

  • allowed_roles (Sequence[int]) – A sequence of role ids that are allowed to interact with the view.

  • timeout (float | None) – Timeout in seconds from last interaction with the UI before no longer accepting input. If None then there is no timeout.

  • message (Message | None) – The message to remove the view from on timeout. This can also be set with view.message = await ctx.send( ... )` , or similar, after the view is instantiated.

__init__(*, allowed_users, allowed_roles, timeout=180.0, message=None)[source]
async interaction_check(interaction)[source]

Ensure the user clicking the button is the view invoker, or a moderator.

Parameters:

interaction (Interaction) – The interaction that occurred.

Return type:

bool

async on_timeout()[source]

Remove the view from self.message if set.

Return type:

None

stop()[source]

Stop listening for interactions, and remove the view from self.message if set.

Return type:

None