Module Contents¶
Classes¶
Represents a UI view. |
|
A page source that requires (field_name, field_value) tuple items. |
|
A data source for a sequence of items. |
|
A data source for a sequence of items. |
|
A simple pagination session reminiscent of the old Pages interface. |
|
A data source for a sequence of items. |
|
A simple paginator for the embeds. In entries you provides a list of embeds |
- class DiscordUtils.paginator.RoboPages(source, *, ctx, check_embeds=True, compact=False)[source]¶
Bases:
discord.ui.View
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
- Parameters
- await interaction_check(self, interaction)[source]¶
This function is a coroutine.
A callback that is called when an interaction happens within the view that checks whether the view should process item callbacks for the interaction.
This is useful to override if, for example, you want to ensure that the interaction author is a given user.
The default implementation of this returns
True
.Note
If an exception occurs within the body then the check is considered a failure and
on_error()
is called.- Parameters
interaction (
Interaction
) – The interaction that occurred.- Returns
Whether the view children’s callbacks should be called.
- Return type
- await on_timeout(self)[source]¶
This function is a coroutine.
A callback that is called when a view’s timeout elapses without being explicitly stopped.
- Return type
- staticmethod await on_error(error, item, interaction)[source]¶
This function is a coroutine.
A callback that is called when an item’s callback or
interaction_check()
fails with an error.The default implementation logs to the library logger.
- await go_to_first_page(self, button, interaction)[source]¶
Go to the first page
- Parameters
button (discord.ui.button.Button) –
interaction (discord.interactions.Interaction) –
- await go_to_previous_page(self, button, interaction)[source]¶
Go to the previous page
- Parameters
button (discord.ui.button.Button) –
interaction (discord.interactions.Interaction) –
- await go_to_current_page(self, button, interaction)[source]¶
As the name suggests, goes to the current page
- Parameters
button (discord.ui.button.Button) –
interaction (discord.interactions.Interaction) –
- await go_to_next_page(self, button, interaction)[source]¶
Go to the next page
- Parameters
button (discord.ui.button.Button) –
interaction (discord.interactions.Interaction) –
- await go_to_last_page(self, button, interaction)[source]¶
Go to the last page
- Parameters
button (discord.ui.button.Button) –
interaction (discord.interactions.Interaction) –
- class DiscordUtils.paginator.FieldPageSource(entries, *, per_page=12)[source]¶
Bases:
discord.ext.menus.ListPageSource
A page source that requires (field_name, field_value) tuple items.
- await format_page(self, menu, entries)[source]¶
This function could be a coroutine.
An abstract method to format the page.
This method must return one of the following types.
If this method returns a
str
then it is interpreted as returning thecontent
keyword argument indiscord.Message.edit()
anddiscord.abc.Messageable.send()
.If this method returns a
discord.Embed
then it is interpreted as returning theembed
keyword argument indiscord.Message.edit()
anddiscord.abc.Messageable.send()
.If this method returns a
dict
then it is interpreted as the keyword-arguments that are used in bothdiscord.Message.edit()
anddiscord.abc.Messageable.send()
. The two of interest areembed
andcontent
.
- class DiscordUtils.paginator.TextPageSource(text, *, prefix='```', suffix='```', max_size=2000)[source]¶
Bases:
discord.ext.menus.ListPageSource
A data source for a sequence of items.
This page source does not handle any sort of formatting, leaving it up to the user. To do so, implement the
format_page()
method.- entries¶
The sequence of items to paginate.
- Type
Sequence[Any]
- await format_page(self, menu, content)[source]¶
This function could be a coroutine.
An abstract method to format the page.
This method must return one of the following types.
If this method returns a
str
then it is interpreted as returning thecontent
keyword argument indiscord.Message.edit()
anddiscord.abc.Messageable.send()
.If this method returns a
discord.Embed
then it is interpreted as returning theembed
keyword argument indiscord.Message.edit()
anddiscord.abc.Messageable.send()
.If this method returns a
dict
then it is interpreted as the keyword-arguments that are used in bothdiscord.Message.edit()
anddiscord.abc.Messageable.send()
. The two of interest areembed
andcontent
.
- class DiscordUtils.paginator.SimplePageSource(entries, *, per_page)[source]¶
Bases:
discord.ext.menus.ListPageSource
A data source for a sequence of items.
This page source does not handle any sort of formatting, leaving it up to the user. To do so, implement the
format_page()
method.- entries¶
The sequence of items to paginate.
- Type
Sequence[Any]
- await format_page(self, menu, entries)[source]¶
This function could be a coroutine.
An abstract method to format the page.
This method must return one of the following types.
If this method returns a
str
then it is interpreted as returning thecontent
keyword argument indiscord.Message.edit()
anddiscord.abc.Messageable.send()
.If this method returns a
discord.Embed
then it is interpreted as returning theembed
keyword argument indiscord.Message.edit()
anddiscord.abc.Messageable.send()
.If this method returns a
dict
then it is interpreted as the keyword-arguments that are used in bothdiscord.Message.edit()
anddiscord.abc.Messageable.send()
. The two of interest areembed
andcontent
.
- class DiscordUtils.paginator.SimplePages(entries, *, ctx, per_page=12)[source]¶
Bases:
RoboPages
A simple pagination session reminiscent of the old Pages interface. Basically an embed with some normal formatting.
- Parameters
ctx (commands.Context) –
per_page (int) –
- class DiscordUtils.paginator.EmbedPageSource(entries, *, per_page)[source]¶
Bases:
discord.ext.menus.ListPageSource
A data source for a sequence of items.
This page source does not handle any sort of formatting, leaving it up to the user. To do so, implement the
format_page()
method.- entries¶
The sequence of items to paginate.
- Type
Sequence[Any]
- staticmethod await format_page(menu, entries)[source]¶
This function could be a coroutine.
An abstract method to format the page.
This method must return one of the following types.
If this method returns a
str
then it is interpreted as returning thecontent
keyword argument indiscord.Message.edit()
anddiscord.abc.Messageable.send()
.If this method returns a
discord.Embed
then it is interpreted as returning theembed
keyword argument indiscord.Message.edit()
anddiscord.abc.Messageable.send()
.If this method returns a
dict
then it is interpreted as the keyword-arguments that are used in bothdiscord.Message.edit()
anddiscord.abc.Messageable.send()
. The two of interest areembed
andcontent
.