5
5
6
6
.. versionadded :: 2.0
7
7
8
- Menus provide a easy pagination system with buttons
8
+ This module provides an easy pagination system with buttons.
9
9
10
- Example:
11
- --------
12
- A Basic Example Of `ext.menus ` Being Used
10
+ Example usage in a cog:
13
11
14
12
.. code-block :: python3
15
13
@@ -23,9 +21,9 @@ A Basic Example Of `ext.menus` Being Used
23
21
self.bot = bot
24
22
25
23
self.pages = [
26
- "Page One",
27
- discord.Embed(title="Page Two"),
28
- discord.Embed(title="Page Three"),
24
+ "Page One", # string (text)
25
+ discord.Embed(title="Page Two"), # rich embed
26
+ discord.Embed(title="Page Three"), # another rich embed
29
27
]
30
28
self.pages[1].set_image(url="https://c.tenor.com/pPKOYQpTO8AAAAAM/monkey-developer.gif")
31
29
self.pages[2].add_field(name="Example Field", value="Example Value", inline=False)
@@ -37,13 +35,19 @@ A Basic Example Of `ext.menus` Being Used
37
35
@slash_command(name="pagetest")
38
36
async def pagetest(self, ctx):
39
37
await ctx.defer()
38
+ # initializing the paginator
40
39
pages = menus.Paginator(pages=self.get_pages(), show_disabled=False, show_indicator=True)
40
+
41
+ # customising buttons
41
42
pages.customize_button("next", button_label=">", button_style=discord.ButtonStyle.green)
42
43
pages.customize_button("prev", button_label="<", button_style=discord.ButtonStyle.green)
43
44
pages.customize_button("first", button_label="<<", button_style=discord.ButtonStyle.blurple)
44
45
pages.customize_button("last", button_label=">>", button_style=discord.ButtonStyle.blurple)
46
+
47
+ # start paginating
45
48
await pages.send(ctx, ephemeral=False)
46
49
50
+ # using a custom view
47
51
@slash_command(name="pagetest_custom")
48
52
async def pagetest_custom(self, ctx):
49
53
await ctx.defer()
@@ -73,4 +77,4 @@ API Reference
73
77
:members:
74
78
75
79
.. autoclass :: discord.ext.menus.PaginatorButton
76
- :members:
80
+ :members:
0 commit comments