nextcord / nextcord-ext-menus

A nextcord menu and pagination extension that makes working with reaction menus and button component menus a bit easier
https://menus.docs.nextcord.dev
MIT License
26 stars 9 forks source link

Allow usage of custom emojis in pagination #15

Closed DenverCoder1 closed 3 years ago

DenverCoder1 commented 3 years ago

Button Menus

Changed usages of emoji.name to str(emoji) since for custom emoji, emoji.name will return just the name (eg. pagefirst), but str(emoji) will return the full emoji (eg. <:pagefirst:899973860772962344>).

When overriding the emoji, the full emoji will need to be specified, so this allows the use of custom emoji in ButtonMenuPages.

Usage of default emojis has been tested and it still works (it is not affected by this change).

Reaction Menus

Changed usage of @button decorator to calls to add_button in order to make it possible to use instance properties (eg. self.FIRST_PAGE) instead of having to use MenuPagesBase.FIRST_PAGE.

Example usage:

Button Menus

class CustomButtonMenuPages(menus.ButtonMenuPages):

    FIRST_PAGE = "<:pagefirst:899973860772962344>"
    PREVIOUS_PAGE = "<:pageprev:899973860965888010>"
    NEXT_PAGE = "<:pagenext:899973860840050728>"
    LAST_PAGE = "<:pagelast:899973860810694686>"
    STOP = "<:stop:899973861444042782>"

# starting the menu
pages = CustomButtonMenuPages(source=MySource(range(1, 100)))
await pages.start(ctx)

Reaction Menus

class CustomMenuPages(menus.MenuPages):

    FIRST_PAGE = "<:pagefirst:899973860772962344>"
    PREVIOUS_PAGE = "<:pageprev:899973860965888010>"
    NEXT_PAGE = "<:pagenext:899973860840050728>"
    LAST_PAGE = "<:pagelast:899973860810694686>"
    STOP = "<:stop:899973861444042782>"

# starting the menu
pages = CustomMenuPages(source=MySource(range(1, 100)))
await pages.start(ctx)
DenverCoder1 commented 3 years ago

Added support for overriding reaction menu pagination emojis as well