{"id":15657369,"url":"https://github.com/necordjs/pagination","last_synced_at":"2025-04-15T21:23:11.875Z","repository":{"id":187723842,"uuid":"677513780","full_name":"necordjs/pagination","owner":"necordjs","description":"📃 A lightweight Pagination module for Necord","archived":false,"fork":false,"pushed_at":"2025-04-10T13:23:18.000Z","size":3020,"stargazers_count":16,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-10T14:51:08.448Z","etag":null,"topics":["discord","discordjs","nest","nestjs","pagination"],"latest_commit_sha":null,"homepage":"https://necord.org/recipes/pagination","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/necordjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["SocketSomeone","necordjs"],"open_collective":"necord"}},"created_at":"2023-08-11T19:13:29.000Z","updated_at":"2025-04-10T13:23:15.000Z","dependencies_parsed_at":"2023-08-11T23:13:23.319Z","dependency_job_id":"afdc0622-9a65-40b7-bff6-0efe685e9354","html_url":"https://github.com/necordjs/pagination","commit_stats":{"total_commits":395,"total_committers":4,"mean_commits":98.75,"dds":"0.15189873417721522","last_synced_commit":"dd4f943aa9d4c9b1fec416ea992bbee6bcd5705a"},"previous_names":["necordjs/pagination"],"tags_count":18,"template":false,"template_full_name":"SocketSomeone/nestjs-open-source-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/necordjs%2Fpagination","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/necordjs%2Fpagination/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/necordjs%2Fpagination/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/necordjs%2Fpagination/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/necordjs","download_url":"https://codeload.github.com/necordjs/pagination/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248243204,"owners_count":21071054,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["discord","discordjs","nest","nestjs","pagination"],"created_at":"2024-10-03T13:06:29.339Z","updated_at":"2025-04-15T21:23:11.843Z","avatar_url":"https://github.com/necordjs.png","language":"TypeScript","funding_links":["https://github.com/sponsors/SocketSomeone","https://github.com/sponsors/necordjs","https://opencollective.com/necord"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n   \u003ch1\u003e\n       \u003ca href=\"#\"\u003e\u003cimg src=\"https://necord.org/img/logo.png\"\u003e\u003c/a\u003e\n   \u003c/h1\u003e\n  📜 A lightweight Pagination module for \u003cb\u003e\u003ca href=\"https://necord.org/\"\u003eNecord\u003c/a\u003e\u003c/b\u003e\n   \u003cbr/\u003e\u003cbr/\u003e\n   \u003ca href=\"https://necord.org\"\u003eDocumentation ✨\u003c/a\u003e \u0026emsp; \u003ca href=\"https://github.com/SocketSomeone/necord\"\u003eSource code 🪡\u003c/a\u003e \u0026emsp; \u003ca href=\"https://github.com/necordjs/samples\"\u003eExamples 🛠️\u003c/a\u003e \u0026emsp; \u003ca href=\"https://discord.gg/mcBYvMTnwP\"\u003eCommunity 💬\u003c/a\u003e\n\u003c/div\u003e\n\n\n\u003cbr/\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href='https://img.shields.io/npm/v/necord'\u003e\u003cimg src=\"https://img.shields.io/npm/v/necord\" alt=\"NPM Version\" /\u003e\u003c/a\u003e\n    \u003ca href='https://img.shields.io/npm/l/necord'\u003e\u003cimg src=\"https://img.shields.io/npm/l/necord\" alt=\"NPM License\" /\u003e\u003c/a\u003e\n    \u003ca href='https://img.shields.io/npm/dm/necord'\u003e\u003cimg src=\"https://img.shields.io/npm/dm/necord\" alt=\"NPM Downloads\" /\u003e\u003c/a\u003e\n    \u003ca href='https://img.shields.io/github/last-commit/necordjs/necord'\u003e\u003cimg src=\"https://img.shields.io/github/last-commit/SocketSomeone/necord\" alt=\"Last commit\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## About\n\nCertainly! Pagination is a useful technique employed in user interfaces to present large amounts of information in a structured and\nmanageable way. When dealing with substantial volumes of data, such as search results, articles, or product listings, presenting it all at\nonce can overwhelm users and lead to a poor user experience. Pagination allows you to divide the information into smaller, organized chunks,\nenhancing user engagement and ease of navigation. This module allows you to create a pagination with a few lines of code.\n\n## Installation\n\n**Node.js 18.0.0 or newer is required.**\n\n```bash\n$ npm i @necord/pagination necord discord.js\n$ yarn add @necord/pagination necord discord.js\n$ pnpm add @necord/pagination necord discord.js\n```\n\n## Usage\n\nOnce the installation process is complete, we can import the `NecordPaginationModule` with your `NecordModule` into the root `AppModule`:\n\n```typescript\nimport { NecordModule } from 'necord';\nimport { Module } from '@nestjs/common';\nimport { NecordPaginationModule } from '@necord/pagination';\nimport { AppService } from './app.service';\n\n@Module({\n    imports: [\n        NecordModule.forRoot({\n            token: 'DISCORD_BOT_TOKEN',\n            intents: ['Guilds', 'GuildMessages', 'DirectMessages']\n        }),\n        NecordPaginationModule.forRoot({\n            // Change your buttons appearance\n            buttons: {},\n            // Add buttons for skip to first and last page\n            allowSkip: true,\n            // Add buttons for search page\n            allowTraversal: true,\n            // Define the buttons position (start / end)\n            buttonsPosition: 'end'\n        })\n    ],\n    providers: [AppService]\n})\nexport class AppModule {\n}\n```\n\nThen, we can inject the `PaginationService` into our service and register a pagination handler:\n\n```typescript\nimport { OnModuleInit, Injectable } from '@nestjs/common';\nimport { NecordPaginationService, PageBuilder } from '@necord/pagination';\nimport { Context, SlashCommand, SlashCommandContext } from 'necord';\n\n@Injectable()\nexport class AppService implements OnModuleInit {\n    public constructor(private readonly paginationService: NecordPaginationService) {\n    }\n\n    public onModuleInit(): void {\n        return this.paginationService.register(builder =\u003e\n            builder\n                // Required, need for search your builder\n                .setCustomId('test')\n                // First way to set pages\n                .setPages([\n                    new PageBuilder().setContent('Page 1'),\n                    new PageBuilder().setContent('Page 2'),\n                    new PageBuilder().setContent('Page 3'),\n                    new PageBuilder().setContent('Page 4'),\n                    new PageBuilder().setContent('Page 5')\n                ])\n                // Second way, you can manually set pages using `setPages` method\n                .setPagesFactory(page =\u003e new PageBuilder().setContent(`Page ${page}`))\n                // Optional, only if you want to use pages factory\n                .setMaxPages(5)\n        );\n    }\n\n    @SlashCommand({ name: 'pagination', description: 'Test pagination' })\n    public async onPagination(@Context() [interaction]: SlashCommandContext) {\n        const pagination = this.paginationService.get('test');\n        const page = await pagination.build();\n\n        return interaction.reply(page);\n    }\n}\n```\n\nCongratulations! You have successfully created your first pagination!\nJust use `pagination` command and you will see your pagination!\n\n## Backers\n\n\u003ca href=\"https://opencollective.com/necord\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/necord/backers.svg?width=1000\"\u003e\u003c/a\u003e\n\n## Stay in touch\n\n* Author - [Alexey Filippov](https://t.me/socketsomeone)\n* Twitter - [@SocketSomeone](https://twitter.com/SocketSomeone)\n\n## License\n\n[MIT](https://github.com/necordjs/necord/blob/master/LICENSE) © [Alexey Filippov](https://github.com/SocketSomeone)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnecordjs%2Fpagination","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnecordjs%2Fpagination","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnecordjs%2Fpagination/lists"}