Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow usage of custom emojis in pagination #15

Merged
merged 10 commits into from
Oct 20, 2021

Conversation

DenverCoder1
Copy link
Collaborator

@DenverCoder1 DenverCoder1 commented Oct 19, 2021

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)

Copy link
Member

@ooliver1 ooliver1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, tested it myself and fully working

@DenverCoder1
Copy link
Collaborator Author

Added support for overriding reaction menu pagination emojis as well

@DenverCoder1 DenverCoder1 marked this pull request as draft October 19, 2021 22:58
@DenverCoder1 DenverCoder1 marked this pull request as ready for review October 19, 2021 23:12
@DenverCoder1 DenverCoder1 changed the title Fix to allow custom emojis in pagination Allow usage of custom emojis in pagination Oct 20, 2021
@DenverCoder1 DenverCoder1 merged commit 19de45f into nextcord:master Oct 20, 2021
@DenverCoder1 DenverCoder1 deleted the custom-emoji-fix branch October 20, 2021 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants