Skip to content

Commit

Permalink
docs fixes, rename module to ext.pages
Browse files Browse the repository at this point in the history
  • Loading branch information
krittick committed Dec 20, 2021
1 parent 6e1ab8e commit 2ed45f7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
discord.ext.menus
discord.ext.pages
~~~~~~~~~~~~~~~~~~~~~
An extension module to provide useful menu options.
Expand Down
File renamed without changes.
30 changes: 15 additions & 15 deletions docs/ext/menus/index.rst → docs/ext/pages/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. _discord_ext_menus:
.. _discord_ext_pages:

``discord.ext.menus`` -- An extension module to provide useful menu options
``discord.ext.pages`` -- An extension module to provide useful pagination options
===========================================================================

.. versionadded:: 2.0
Expand All @@ -13,7 +13,7 @@ Example usage in a cog:
import discord
from discord.commands import slash_command
from discord.ext import commands, menus
from discord.ext import commands, pages
class PageTest(commands.Cog):
Expand All @@ -36,16 +36,16 @@ Example usage in a cog:
async def pagetest(self, ctx):
await ctx.defer()
# initializing the paginator
pages = menus.Paginator(pages=self.get_pages(), show_disabled=False, show_indicator=True)
paginator = menus.Paginator(pages=self.get_pages(), show_disabled=False, show_indicator=True)
# customising buttons
pages.customize_button("next", button_label=">", button_style=discord.ButtonStyle.green)
pages.customize_button("prev", button_label="<", button_style=discord.ButtonStyle.green)
pages.customize_button("first", button_label="<<", button_style=discord.ButtonStyle.blurple)
pages.customize_button("last", button_label=">>", button_style=discord.ButtonStyle.blurple)
paginator.customize_button("next", button_label=">", button_style=discord.ButtonStyle.green)
paginator.customize_button("prev", button_label="<", button_style=discord.ButtonStyle.green)
paginator.customize_button("first", button_label="<<", button_style=discord.ButtonStyle.blurple)
paginator.customize_button("last", button_label=">>", button_style=discord.ButtonStyle.blurple)
# start paginating
await pages.send(ctx, ephemeral=False)
await paginator.send(ctx, ephemeral=False)
# using a custom view
@slash_command(name="pagetest_custom")
Expand All @@ -59,22 +59,22 @@ Example usage in a cog:
options=[discord.SelectOption(label="Example Option", value="Example Value", description="This menu does nothing!")],
)
)
pages = menus.Paginator(pages=self.get_pages(), show_disabled=False, show_indicator=True, custom_view=view)
await pages.send(ctx, ephemeral=False)
paginator = menus.Paginator(pages=self.get_pages(), show_disabled=False, show_indicator=True, custom_view=view)
await paginator.send(ctx, ephemeral=False)
def setup(bot):
bot.add_cog(PageTest(bot))
.. _discord_ext_menus_api:
.. _discord_ext_pages_api:

API Reference
-------------

.. attributetable:: discord.ext.menus.Paginator
.. attributetable:: discord.ext.pages.Paginator

.. autoclass:: discord.ext.menus.Paginator
.. autoclass:: discord.ext.pages.Paginator
:members:

.. autoclass:: discord.ext.menus.PaginatorButton
.. autoclass:: discord.ext.pages.PaginatorButton
:members:
20 changes: 11 additions & 9 deletions examples/views/paginator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Docs: https://docs.pycord.dev/en/master/ext/pages/index.html

import discord
from discord.commands import slash_command
from discord.ext import commands, menus
from discord.ext import commands, pages


class PageTest(commands.Cog):
Expand All @@ -22,12 +24,12 @@ def get_pages(self):
@slash_command(name="pagetest")
async def pagetest(self, ctx):
await ctx.defer()
pages = menus.Paginator(pages=self.get_pages(), show_disabled=False, show_indicator=True)
pages.customize_button("next", button_label=">", button_style=discord.ButtonStyle.green)
pages.customize_button("prev", button_label="<", button_style=discord.ButtonStyle.green)
pages.customize_button("first", button_label="<<", button_style=discord.ButtonStyle.blurple)
pages.customize_button("last", button_label=">>", button_style=discord.ButtonStyle.blurple)
await pages.send(ctx, ephemeral=False)
paginator = pages.Paginator(pages=self.get_pages(), show_disabled=False, show_indicator=True)
paginator.customize_button("next", button_label=">", button_style=discord.ButtonStyle.green)
paginator.customize_button("prev", button_label="<", button_style=discord.ButtonStyle.green)
paginator.customize_button("first", button_label="<<", button_style=discord.ButtonStyle.blurple)
paginator.customize_button("last", button_label=">>", button_style=discord.ButtonStyle.blurple)
await paginator.send(ctx, ephemeral=False)

@slash_command(name="pagetest_custom")
async def pagetest_custom(self, ctx):
Expand All @@ -40,8 +42,8 @@ async def pagetest_custom(self, ctx):
options=[discord.SelectOption(label="Example Option", value="Example Value", description="This menu does nothing!")],
)
)
pages = menus.Paginator(pages=self.get_pages(), show_disabled=False, show_indicator=True, custom_view=view)
await pages.send(ctx, ephemeral=False)
paginator = menus.Paginator(pages=self.get_pages(), show_disabled=False, show_indicator=True, custom_view=view)
await paginator.send(ctx, ephemeral=False)


def setup(bot):
Expand Down

0 comments on commit 2ed45f7

Please sign in to comment.