Custom Buttons¶
The extension provides a way to customise the buttons used in the paginator.
- class discord.ext.modal_paginator.CustomButton[source]¶
-
Custom button class to pass to the
buttonskwarg inModalPaginator.This can be used to override things of the default buttons. like the label, style, row, etc.
Parameters docs below is partially copied from
discord.ui.Button.- Parameters:
style (
discord.ButtonStyle]) – The new style of the button.label (
str) – The new label of the button.emoji (Union[
discord.PartialEmoji,discord.Emoji,str]) – The new emoji of the button. (If any)row (
int) – The new row of the button. Seediscord.ui.Buttonfor more info.override_callback (Optional[
bool]) – Whether to override the callback of the button. Defaults toFalse. IfTrue, your callback will be called instead of the one on the paginator.
- async callback(interaction)[source]¶
The callback for the button.
This is called if
override_callbackis set toTrue.- Parameters:
interaction (
Interaction) – The interaction that triggered the callback.- Return type:
- on_optional_modal(button)[source]¶
This method is called when the
current_modalis optional.This can be used to change the button’s style, label, etc. Might want to use this to revert the changes made in
on_required_modal().
- on_required_modal(button)[source]¶
This method is called when the
current_modalis required butdiscord.ui.Modal.is_finished()isFalse.This can be used to change the button’s style, label, etc. This should be used in conjunction with
on_optional_modal().
Default Buttons¶
See here the default buttons used in the paginator. These are for reference only, and should not be used directly.
OpenButton¶
- discord.ext.modal_paginator.default_buttons.OpenButton¶
Represents the default open button for
ModalPaginator.Default implementation is,
(style=discord.ButtonStyle.gray, label="Open", row=0).This overrides the
on_optional_modalandon_required_modalmethods to change the label and style.
- OpenButton.on_required_modal()¶
Called when the modal is required.
This changes the label to
"*Open"and the style todiscord.ButtonStyle.blurple.- Return type:
NextButton¶
- discord.ext.modal_paginator.default_buttons.NextButton¶
Represents the default next button for
ModalPaginator.Default implementation is,
(label="Next", style=discord.ButtonStyle.green, row=1).
PreviousButton¶
- discord.ext.modal_paginator.default_buttons.PreviousButton¶
Represents the default previous button for
ModalPaginator.Default implementation is,
(label="Previous", style=discord.ButtonStyle.green, row=1).
CancelButton¶
- discord.ext.modal_paginator.default_buttons.CancelButton¶
Represents the default cancel button for
ModalPaginator.Default implementation is,
(label="Cancel", style=discord.ButtonStyle.red, row=2).
FinishButton¶
- discord.ext.modal_paginator.default_buttons.FinishButton¶
Represents the default finish button for
ModalPaginator.Default implementation is,
(label="Finish", style=discord.ButtonStyle.green, row=2).