feat: paginate /codes with prev/next buttons#32
Merged
Conversation
Owner
BigMichi1
commented
May 17, 2026
- Remove the count option from /codes (was capped at 20)
- Add getRedeemedCodeCount() to codeManager for total page calculation
- Add offset parameter to getRedeemedCodeDetails() for slicing
- Build pages of 5 codes with disabled-aware ◀ Prev / Next ▶ buttons
- Button custom IDs encode the owner's Discord ID so only they can page
- Handle button interactions in bot.ts via a dedicated InteractionCreate listener
- Add tests: limit, offset/pagination, count (8 new tests, 169 pass total)
- Remove the count option from /codes (was capped at 20) - Add getRedeemedCodeCount() to codeManager for total page calculation - Add offset parameter to getRedeemedCodeDetails() for slicing - Build pages of 5 codes with disabled-aware ◀ Prev / Next ▶ buttons - Button custom IDs encode the owner's Discord ID so only they can page - Handle button interactions in bot.ts via a dedicated InteractionCreate listener - Add tests: limit, offset/pagination, count (8 new tests, 169 pass total) Signed-off-by: Michael Cramer <michael@bigmichi1.de>
✅ Coverage Report
Changed Files
|
There was a problem hiding this comment.
Pull request overview
Replaces the count option on /codes with proper Discord pagination using Prev/Next buttons. Each page shows 5 redeemed codes; the buttons' custom IDs encode the invoking user's Discord ID so only they can paginate, with a dedicated InteractionCreate listener in bot.ts handling the button events.
Changes:
- Add
getRedeemedCodeCount()and anoffsetparameter togetRedeemedCodeDetails()incodeManager. - Refactor
/codesinto a reusablebuildCodesPage()producing an embed plus Prev/Next button row; also corrects the status emoji key fromexpiredtocode expiredand trims the public badge text. - Register a new button-interaction listener in
bot.tsthat validates ownership and re-renders the requested page; mark the item complete inIDEAS/TODO.md.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/bot/database/codeManager.ts | Adds count query and offset parameter to support pagination. |
| src/bot/database/codeManager.test.ts | New tests covering limit, offset, and count behavior. |
| src/bot/commands/codes.ts | Extracts page-building logic, removes count option, adds button row. |
| src/bot/bot.ts | Adds a button interaction listener that dispatches codes: paging events. |
| IDEAS/TODO.md | Marks the paginated /codes item as implemented. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.