Skip to content

Merge LTS to Latest#10

Merged
Abadima merged 39 commits into
latestfrom
LTS
Jan 26, 2026
Merged

Merge LTS to Latest#10
Abadima merged 39 commits into
latestfrom
LTS

Conversation

@Abadima

@Abadima Abadima commented Jan 26, 2026

Copy link
Copy Markdown
Owner

No description provided.

Abadima added 6 commits August 6, 2023 22:47
DEPENDENCY UPDATES:
- @napi-rs/canvas => v0.1.41
- mongoose => v7.4.2

BUG FIXES:
- xp.rank() error
- xp.chart() now has a helpful err message
- leaderboard() Position & Cache issues

TYPE IMPROVEMENTS:
- addLevel() => Make Code Prettier
- addXP() => Make Code Prettier
- charts() => Make Code Prettier
- leaderboard() => Ensured limit was optional for TypeScript users
- rank() => Cure Cancer (Remove Unnecessary Statements)

UPDATES:
- Added eslint (dev)
- rank() => Moved Funcs (eslint compliant)
- connect() => "auto_purge" option, basically does what it did in Beta 7, but you have a choice (false by default)
Bug Fixes
⭐ Improvements

- Refactor leaderboard and rank position calculation into a new utility for efficiency and code reuse.
- Add a compound index to the level model for improved leaderboard query performance.
- Improve leaderboard auto-purge logic and cleaned up code style.
- Refactor `rank()` image to scale background images properly, fixing stretching issues.

💎 Design Changes

- Replace `Baloo-Regular.ttf` to `Baloo2-Regular.woff2` for better performance and smaller size.

⬆️ Dependencies

- Bump `@napi-rs/canvas` from `v0.1.43` to `v0.1.88`.
Extracted level up notification and XP shortener functions into separate utility modules for better code reuse and maintainability. Updated addLevel, setLevel, fetch, leaderboard, and rank modules to use these utilities. Also simplified ESLint config file patterns and bumped package version to 1.3.8-fix.0.
Extracted the repeated level payload construction logic from addLevel.js and setLevel.js into a new utility function, buildLevelPayload, in src/utils/levelPayload.js. This improves code reuse and maintainability.
Repository owner deleted a comment from codacy-production Bot Jan 26, 2026
@codacy-production

codacy-production Bot commented Jan 26, 2026

Copy link
Copy Markdown

Codacy's Analysis Summary

100 new issues (≤ 0 medium issue)
1 new security issue (≤ 0 issue)
13 complexity
-15 duplications

Review Pull Request in Codacy →

AI Reviewer available: add the codacy-review label to get contextual insights without leaving GitHub.

Improved leaderboard logic for robustness and variable clarity. Added JSDoc comments to utility functions for better documentation. Minor cleanup in addLevel and setLevel by removing unused variables. Updated README with new badges and improved formatting.
Improves leaderboard entry handling by cloning objects before destructuring, enhancing data safety. Refactors shortener to handle non-numeric input and index bounds more robustly. Updates README for improved clarity and formatting.
Updated leaderboard position calculation to use entryIndex for accuracy and refactored the loop to use for...of. Improved shortener function by safely handling suffix assignment. Also standardized formatting and type definitions in index.d.ts for consistency.
@Abadima

Abadima commented Jan 26, 2026

Copy link
Copy Markdown
Owner Author

I give up trying to please codacy, there isn't a way to do it rn without creating really silly looking code, even with copilot's assistance

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR appears to modernize the codebase (“Merge LTS to Latest”) by refactoring shared XP/leveling utilities, adjusting leaderboard/rank computation, and updating project metadata/tooling.

Changes:

  • Added shared utility modules (short number formatting, level-up notification, leaderboard position lookup).
  • Refactored rank/leaderboard/fetch logic to use shared helpers and added a DB index for guild XP sorting.
  • Updated package metadata (deps, eslint config, docs/readme, ignore files) and introduced a module-level options config.

Reviewed changes

Copilot reviewed 25 out of 29 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/utils/shortener.js New shared number-shortening helper.
src/utils/levelUpNotifier.js New helper to emit levelUp with resolved role config.
src/utils/levelPayload.js New helper to standardize levelUp payload shape.
src/utils/getUserPosition.js New cursor-based helper to compute leaderboard position without loading whole list.
src/setXP.js Refactors XP set logic to use findOneAndUpdate.
src/setLevel.js Refactors level set logic and extracts notification/payload creation.
src/roleSetup.js Formatting/string consistency updates.
src/reset.js Formatting update of errors and query call.
src/rank.js Uses shared shortener + position helper; rank card rendering refactor.
src/models/lvlrole.js Formatting/string consistency updates.
src/models/level.js Adds { guild, xp } index; formatting updates.
src/lvlRole.js Formatting/string consistency updates.
src/leaderboard.js Reworks leaderboard construction and adds optional auto-purge behavior.
src/fetch.js Uses shared shortener + position helper.
src/create.js Formatting update of errors and DB insert behavior.
src/connect.js Formatting changes and modifies notify behavior.
src/charts.js Switches to @napi-rs/canvas usage and formatting updates.
src/addXP.js Formatting/string consistency updates.
src/addLevel.js Uses new payload/notifier helper instead of inline emission logic.
src/Fonts/Baloo2-Regular.woff2 Adds new font asset used by rank card.
simplyxp.js Adds exported options object and standardizes require/export formatting.
package.json Updates version/metadata, dependencies, scripts, keywords, and repo links.
index.d.ts Reformats typings and adjusts some option types.
eslint.config.cjs Adds ESLint flat config (replaces .eslintrc.json).
README.md Updates badges, copy, and formatting.
.npmignore Expands ignored files for publishing.
.gitignore Updates ignored files (pnpm lock/workspace).
.eslintrc.json Removes legacy ESLint config.
Comments suppressed due to low confidence (1)

src/models/level.js:6

  • The schema marks user as globally unique, but all queries in this package are keyed by { user, guild }. This uniqueness constraint will prevent the same user from having XP in multiple guilds. Consider removing unique: true on user and adding a compound unique index on { user: 1, guild: 1 } instead.
const Levelz = new mongoose.Schema({
	user: { type: String, unique: true },
	guild: { type: String },
	xp: { type: Number, default: 0 },

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/leaderboard.js Outdated
Comment thread src/create.js Outdated
Comment thread src/setXP.js
Comment thread src/setLevel.js Outdated
Comment thread src/reset.js Outdated
Comment thread src/setXP.js Outdated
Comment thread src/setLevel.js
Comment thread src/addLevel.js Outdated
Comment thread src/setXP.js Outdated
Comment thread src/setLevel.js Outdated
Abadima and others added 6 commits January 25, 2026 23:46
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Allow xp = 0

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Remove unnecessary const

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI commented Jan 26, 2026

Copy link
Copy Markdown
Contributor

@Abadima I've opened a new pull request, #11, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 3 commits January 26, 2026 04:55
Co-authored-by: Abadima <39747270+Abadima@users.noreply.github.com>
Fix levelUp event emission logic in addLevel

Copilot AI commented Jan 26, 2026

Copy link
Copy Markdown
Contributor

@Abadima I've opened a new pull request, #12, to work on those changes. Once the pull request is ready, I'll request review from you.

@codacy-production

codacy-production Bot commented Jan 26, 2026

Copy link
Copy Markdown

Codacy's Analysis Summary

100 new issues (≤ 0 medium issue)
0 new security issue (≤ 0 issue)
21 complexity
-15 duplications

Review Pull Request in Codacy →

AI Reviewer available: add the codacy-review label to get contextual insights without leaving GitHub.

Abadima and others added 3 commits January 26, 2026 00:07
Fix setLevel to capture previous level before update
Fix type coercion in setLevel to prevent incorrect event emission

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 25 out of 29 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/addLevel.js Outdated
Comment thread src/setLevel.js Outdated
Comment thread src/utils/shortener.js Outdated
Comment on lines +10 to +13
async function notifyLevelUp(message, data, roleLevel) {
const role = await roleSetup.find(message.client, data.guildID, roleLevel);
message.client.emit("levelUp", message, data, role);
}

Copilot AI Jan 26, 2026

Copy link

Choose a reason for hiding this comment

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

Indentation here uses spaces instead of tabs, which will fail the repo’s ESLint indent: ["error", "tab"] rule.

Copilot uses AI. Check for mistakes.
Comment thread src/rank.js
Comment thread src/connect.js
@Abadima

Abadima commented Jan 26, 2026

Copy link
Copy Markdown
Owner Author

@copilot open a new pull request to apply changes based on the comments in this thread

Copilot AI commented Jan 26, 2026

Copy link
Copy Markdown
Contributor

@Abadima I've opened a new pull request, #15, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 3 commits January 26, 2026 05:27
…n, member checks, and logging

Co-authored-by: Abadima <39747270+Abadima@users.noreply.github.com>
Co-authored-by: Abadima <39747270+Abadima@users.noreply.github.com>
Fix level emission, negative number handling, and member validation issues
@Abadima

Abadima commented Jan 26, 2026

Copy link
Copy Markdown
Owner Author

@copilot your suggestions have been granted, plz approve review

Copilot AI commented Jan 26, 2026

Copy link
Copy Markdown
Contributor

@Abadima I've opened a new pull request, #16, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 25 out of 29 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/addXP.js Outdated
Comment thread src/leaderboard.js Outdated
Comment thread src/connect.js
Comment thread src/rank.js
Comment thread eslint.config.cjs Outdated
Comment thread src/addLevel.js Outdated
@Abadima

Abadima commented Jan 26, 2026

Copy link
Copy Markdown
Owner Author

@copilot open a new pull request to apply changes based on the comments in this thread

Copilot AI mentioned this pull request Jan 26, 2026
9 tasks

Copilot AI commented Jan 26, 2026

Copy link
Copy Markdown
Contributor

@Abadima I've opened a new pull request, #17, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 4 commits January 26, 2026 05:51
Co-authored-by: Abadima <39747270+Abadima@users.noreply.github.com>
Co-authored-by: Abadima <39747270+Abadima@users.noreply.github.com>
Co-authored-by: Abadima <39747270+Abadima@users.noreply.github.com>
@codacy-production

Copy link
Copy Markdown

Codacy's Analysis Summary

100 new issues (≤ 0 medium issue)
0 new security issue (≤ 0 issue)
29 complexity
-13 duplications

Review Pull Request in Codacy →

AI Reviewer available: add the codacy-review label to get contextual insights without leaving GitHub.

@Abadima
Abadima merged commit 6d2e9a3 into latest Jan 26, 2026
1 check failed
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.

3 participants