Package: pygicord
PygicordAn easy-to-use feature-rich pagination wrapper for discord.pyContentsInstallingGetting StartedBasic PaginatorAttributesCustom EmojisConfigurationCustom PaginatorNew PaginatorInstallingpipinstallpygicordor via git:pipinstallgit+https://github.com/davidetacchini/pygicordNoteIt is recommended using the latest stable version ofdiscord.py.Getting StartedBasic PaginatorfrompygicordimportPaginatordefget_pages():pages=[]foriinrange(1,6):embed=discord.Embed()embed.title=f"Embed no.{i}"pages.append(embed)returnpages@bot.command()asyncdeftest(ctx):pages=get_pages()paginator=Paginator(pages=pages)awaitpaginator.start(ctx)AttributesNameDescriptionTypeDefaultpagesA list of objects to paginate or just one.Union[Any, List[Any]]embed_linksWhether to check for Embed Links permission.boolTruetimeoutThe timeout to wait before stopping the pagination session.float90.0emojisThe custom emojis to use.Mapping[str, str]Discord nativesconfigThe configuration to use.pygicord.ConfigConfig.DEFAULTforce_lockWhether to force adding the lock.boolFalseemojis attribute is a Mapping of old emoji codes to new emoji codes. Keep reading to understand how to set your custom emojis.force_lock adds a reaction that allows the author of the message to share/unshare the reaction controller to other server members.Supported emojis formats:Emoji: "🚀" (not recommended)Unicode: "\U0001F680"Unicode name: "\N{ROCKET}"Custom emoji: ":custom_emoji:123456"Custom EmojisfrompygicordimportPaginator# copy this and replace the values.custom_emojis={"\U000023EA":"REPLACE (first page)","\U000025C0":"REPLACE (previous page)","\U000023F9":"REPLACE (stop session)","\U000025B6":"REPLACE (next page)","\U000023E9":"REPLACE (last page)","\U0001F522":"REPLACE (input numbers)","\U0001F512":"REPLACE (lock unlock)",}@bot.commandasyncdeftest(ctx):paginator=Paginator(pages=pages,emojis=custom_emojis)awaitpaginator.start(ctx)ConfigurationConfig.RICH is the only configuration to have the lock set by default.
You must setforce_lockto True if you want to add it to all other configurations.TypeControllerConfig.DEFAULTfirst, previous, stop, next, last, inputConfig.MINIMALprevious, stop, nextConfig.PLAINfirst, previous, stop, next, lastConfig.RICHfirst, previous, stop, next, last, input, lockControlActionfirstJump to first pagepreviousGo to next pagestopStop pagination sessionnextGo to next pagelastJump to last pageinputEnter a page number to jump toinputShare/unshare the reaction controller to other server members.frompygicordimportConfig,Paginator@bot.command()asyncdeftest(ctx):paginator=Paginator(pages=pages,config=Config.MINIMAL)awaitpaginator.start(ctx)Custom PaginatorfrompygicordimportPaginator,controlclassCustomPaginator(Paginator):@control(emoji="\N{INFORMATION SOURCE}",position=4.5)asyncdefshow_info(self,payload):"""Shows this message."""desc=[]foremoji,control_inself.controller.items():desc.append(f"{emoji}:{control_.callback.__doc__}")embed=discord.Embed()embed.description="\n".join(desc)embed.set_footer(text="Press any reaction to go back.")awaitself.message.edit(content=None,embed=embed)pages=[f"Page no.{i}"foriinrange(1,6)]@bot.command()asyncdeftest(ctx):paginator=CustomPaginator(pages=pages)awaitpaginator.start(ctx)New PaginatorfrompygicordimportBase,StopAction,StopPagination,controlclassMyPaginator(Base):@control(emoji="\N{BLACK SQUARE FOR STOP}",position=2)asyncdefstop(self,payload):"""Stop pagination."""raiseStopPagination(StopAction.DELETE_MESSAGE)@stop.display_ifdefstop_display_if(self):"""Only displays when pages are atleast 2."""returnlen(self)>1@stop.invoke_ifdefstop_invoke_if(self,payload):"""Only the author can stop the session."""returnself.ctx.author.id==payload.user_idpages=[f"Page no.{i}"foriinrange(1,6)]@bot.command()asyncdeftest(ctx):paginator=MyPaginator(pages=pages)awaitpaginator.start(ctx)You can find more exhaustive examples in the examples folder.