@@ -34,12 +34,11 @@ class PaginatorButton(discord.ui.Button):
34
34
35
35
Parameters
36
36
----------
37
-
38
37
button_type: :class:`str`
39
38
The type of button being created.
40
39
Must be one of ``first``, ``prev``, ``next``, or ``last``.
41
40
paginator: :class:`Paginator`
42
- The Paginator class where this button will be used
41
+ The paginator class where this button will be used.
43
42
"""
44
43
45
44
def __init__ (self , label , emoji , style , disabled , button_type , paginator ):
@@ -69,30 +68,30 @@ class Paginator(discord.ui.View):
69
68
Attributes
70
69
----------
71
70
current_page: :class:`int`
72
- Zero -indexed value showing the current page number
71
+ A zero -indexed value showing the current page number.
73
72
page_count: :class:`int`
74
- Zero -indexed value showing the total number of pages
73
+ A zero -indexed value showing the total number of pages.
75
74
buttons: Dict[:class:`str`, Dict[:class:`str`, Union[:class:`~PaginatorButton`, :class:`bool`]]]
76
- Dictionary containing the :class:`~PaginatorButton` objects included in this Paginator
75
+ A dictionary containing the :class:`~PaginatorButton` objects included in this paginator.
77
76
user: Optional[Union[:class:`~discord.User`, :class:`~discord.Member`]]
78
- The user or member that invoked the Paginator .
77
+ The user or member that invoked the paginator .
79
78
message: Union[:class:`~discord.Message`, :class:`~discord.WebhookMessage`]
80
- The message sent from the Paginator .
79
+ The message the paginator is attached to .
81
80
82
81
Parameters
83
82
----------
84
83
pages: Union[List[:class:`str`], List[:class:`discord.Embed`]]
85
- Your list of strings or embeds to paginate
84
+ The list of strings and/ or embeds to paginate.
86
85
show_disabled: :class:`bool`
87
- Choose whether or not to show disabled buttons
86
+ Whether to show disabled buttons.
88
87
show_indicator: :class:`bool`
89
- Choose whether to show the page indicator
88
+ Whether to show the page indicator.
90
89
author_check: :class:`bool`
91
- Choose whether or not only the original user of the command can change pages
90
+ Whether only the original user of the command can change pages.
92
91
disable_on_timeout: :class:`bool`
93
- Should the buttons be disabled when the pagintator view times out?
92
+ Whether the buttons get disabled when the pagintator view times out.
94
93
custom_view: Optional[:class:`discord.ui.View`]
95
- A custom view whose items are appended below the pagination buttons
94
+ A custom view whose items are appended below the pagination buttons.
96
95
"""
97
96
98
97
def __init__ (
@@ -104,7 +103,7 @@ def __init__(
104
103
disable_on_timeout = True ,
105
104
custom_view : Optional [discord .ui .View ] = None ,
106
105
timeout : Optional [float ] = 180.0 ,
107
- ):
106
+ ) -> None :
108
107
super ().__init__ (timeout = timeout )
109
108
self .timeout = timeout
110
109
self .pages = pages
@@ -114,7 +113,7 @@ def __init__(
114
113
self .show_indicator = show_indicator
115
114
self .disable_on_timeout = disable_on_timeout
116
115
self .custom_view = custom_view
117
- self .message : Union [discord .Message , discord .WebhookMessage ]
116
+ self .message : Union [discord .Message , discord .WebhookMessage , None ] = None
118
117
self .buttons = {
119
118
"first" : {
120
119
"object" : PaginatorButton (
@@ -182,7 +181,7 @@ async def on_timeout(self) -> None:
182
181
item .disabled = True
183
182
await self .message .edit (view = self )
184
183
185
- async def goto_page (self , interaction : discord .Interaction , page_number = 0 ):
184
+ async def goto_page (self , interaction : discord .Interaction , page_number = 0 ) -> None :
186
185
"""Updates the interaction response message to show the specified page number.
187
186
188
187
Parameters
@@ -195,47 +194,43 @@ async def goto_page(self, interaction: discord.Interaction, page_number=0):
195
194
.. note::
196
195
197
196
Page numbers are zero-indexed when referenced internally, but appear as one-indexed when shown to the user.
198
-
199
- Returns
200
- ---------
201
- :class:`~Paginator`
202
- The Paginator class
203
197
"""
204
198
self .update_buttons ()
205
199
page = self .pages [page_number ]
206
200
await interaction .response .edit_message (
207
201
content = page if isinstance (page , str ) else None , embed = page if isinstance (page , discord .Embed ) else None , view = self
208
202
)
209
203
210
- async def interaction_check (self , interaction ) :
204
+ async def interaction_check (self , interaction : discord . Interaction ) -> bool :
211
205
if self .usercheck :
212
206
return self .user == interaction .user
213
207
return True
214
208
215
209
def customize_button (
216
210
self , button_name : str = None , button_label : str = None , button_emoji = None , button_style : discord .ButtonStyle = discord .ButtonStyle .gray
217
- ) -> Union [ PaginatorButton , bool ] :
211
+ ) -> PaginatorButton :
218
212
"""Allows you to easily customize the various pagination buttons.
219
213
220
214
Parameters
221
215
----------
222
216
button_name: :class:`str`
223
- Name of the button to customize
217
+ The name of the button to customize.
218
+ Must be one of ``first``, ``prev``, ``next``, or ``last``.
224
219
button_label: :class:`str`
225
- Label to display on the button
220
+ The label to display on the button.
226
221
button_emoji:
227
- Emoji to display on the button
222
+ The emoji to display on the button.
228
223
button_style: :class:`~discord.ButtonStyle`
229
- ButtonStyle to use for the button
224
+ The ButtonStyle to use for the button.
230
225
231
226
Returns
232
227
-------
233
228
:class:`~PaginatorButton`
234
- The button that was customized
229
+ The button that was customized.
235
230
"""
236
231
237
232
if button_name not in self .buttons .keys ():
238
- return False
233
+ raise ValueError ( f"no button named { button_name } was found in this view." )
239
234
button : PaginatorButton = self .buttons [button_name ]["object" ]
240
235
button .label = button_label
241
236
button .emoji = button_emoji
@@ -248,7 +243,7 @@ def update_buttons(self) -> Dict:
248
243
Returns
249
244
-------
250
245
Dict[:class:`str`, Dict[:class:`str`, Union[:class:`~PaginatorButton`, :class:`bool`]]]
251
- The dictionary of buttons that was updated.
246
+ The dictionary of buttons that were updated.
252
247
"""
253
248
for key , button in self .buttons .items ():
254
249
if key == "first" :
@@ -294,7 +289,7 @@ def update_buttons(self) -> Dict:
294
289
295
290
return self .buttons
296
291
297
- async def send (self , messageable : abc .Messageable , ephemeral : bool = False ):
292
+ async def send (self , messageable : abc .Messageable , ephemeral : bool = False ) -> Union [ discord . Message , discord . WebhookMessage ] :
298
293
"""Sends a message with the paginated items.
299
294
300
295
@@ -308,7 +303,7 @@ async def send(self, messageable: abc.Messageable, ephemeral: bool = False):
308
303
Returns
309
304
--------
310
305
Union[:class:`~discord.Message`, :class:`~discord.WebhookMessage`]
311
- The message that was sent with the Paginator .
306
+ The message that was sent with the paginator .
312
307
"""
313
308
314
309
if not isinstance (messageable , abc .Messageable ):
@@ -354,7 +349,7 @@ async def respond(self, interaction: discord.Interaction, ephemeral: bool = Fals
354
349
Returns
355
350
--------
356
351
:class:`~discord.Interaction`
357
- The message sent with the paginator
352
+ The message sent with the paginator.
358
353
"""
359
354
page = self .pages [0 ]
360
355
self .user = interaction .user
0 commit comments