Added module name-list-cleaner#178
Added module name-list-cleaner#178hfgd123 wants to merge 7 commits intoScootKit:beta-discordjs14from
Conversation
as per Sukram2.0's suggestion also added tabs in en.json...
There was a problem hiding this comment.
Pull request overview
Adds a new name-list-cleaner module intended to sanitize member display names by stripping leading special characters, and wires it into member update + bot ready events with accompanying English localization strings.
Changes:
- Introduces the
name-list-cleanermodule metadata, configuration schema, and event handlers. - Implements
renameMember/checkUsernamelogic to compute a cleaned nickname (or reset nickname depending on config). - Updates
locales/en.jsonformatting and addsname-list-cleanerlocale keys.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| modules/name-list-cleaner/renameMember.js | Core renaming logic and username sanitization helper. |
| modules/name-list-cleaner/module.json | Module metadata registration (name, author, tags, config examples). |
| modules/name-list-cleaner/events/guildMemberUpdate.js | Triggers sanitization on nickname/username changes. |
| modules/name-list-cleaner/events/botReady.js | Sanitizes all cached members on startup. |
| modules/name-list-cleaner/configs/config.json | Defines configurable behavior (whitelist/blacklist, user whitelist, etc.). |
| locales/en.json | Adds localized strings for the new module and adjusts indentation in the ping-protection section. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hi, quickly checking in, any updates on this? |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Currently working through the suggestions. I didn't get a notification when Copilot answered 😅 |
- added error handling in case of a nickname reset - fixed empty symbol whitelist - changed handling of names only containing empty characters - changed openSourceURL according to module rename
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Sorry, my bad, forgot to comment with the usal comment: Hi, thanks so much for your contribution. Also, I have one question for our internal compliance:
|
|
No problem. About the LLM thing: Yes, GitHub Copilot was used (for completion of sigular lines and for writing some of the Strings that are shown to users). I didn't check the AI code specifically, but I tested the module as a whole. I can try to find out how to resolve the conflicts |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| renameMember = async function (client, guildMember) { | ||
| let newName; |
There was a problem hiding this comment.
renameMember is assigned without const/let/function declaration, which creates an implicit global variable in non-strict mode and can lead to hard-to-debug collisions. Declare it explicitly (e.g., const renameMember = … or async function renameMember(…)).
| if (name.charAt(0).match(/^[a-zA-Z0-9]$/)) { | ||
| return name; | ||
| } else { | ||
| return await checkUsername(client, name.substring(1), isUsername); | ||
| } | ||
| } else if (!moduleConf.symbolWhitelist.includes(name.charAt(0)) && !moduleConf.isBlacklist) { | ||
| if (name.charAt(0).match(/^[a-zA-Z0-9]$/)) { |
There was a problem hiding this comment.
checkUsername treats only ASCII [a-zA-Z0-9] as alphanumeric. This will strip leading non-ASCII letters/digits (e.g., ü/ß/Ж/漢/١) even though they are valid characters in Discord names, causing unexpected renames. Consider using a Unicode-aware check (e.g., Unicode property escapes) or clarify the intended restriction.
| if (name.charAt(0).match(/^[a-zA-Z0-9]$/)) { | |
| return name; | |
| } else { | |
| return await checkUsername(client, name.substring(1), isUsername); | |
| } | |
| } else if (!moduleConf.symbolWhitelist.includes(name.charAt(0)) && !moduleConf.isBlacklist) { | |
| if (name.charAt(0).match(/^[a-zA-Z0-9]$/)) { | |
| if (name.charAt(0).match(/^[\p{L}\p{N}]$/u)) { | |
| return name; | |
| } else { | |
| return await checkUsername(client, name.substring(1), isUsername); | |
| } | |
| } else if (!moduleConf.symbolWhitelist.includes(name.charAt(0)) && !moduleConf.isBlacklist) { | |
| if (name.charAt(0).match(/^[\p{L}\p{N}]$/u)) { |
There was a problem hiding this comment.
If you want it to accept anything else, you can whitelist it, ig
There was a problem hiding this comment.
imagine whitelisting every chinese character
There was a problem hiding this comment.
true... But at the same time: Where would you draw the line
|
|
||
| if (!client.botReadyAt) return; | ||
| if (newGuildMember.guild.id !== client.guild.id) return; | ||
| if (oldGuildMember.nickname === newGuildMember.nickname && oldGuildMember.user.username === newGuildMember.user.username) return; |
There was a problem hiding this comment.
guildMemberUpdate generally won’t fire for global username changes (those emit userUpdate), so the oldGuildMember.user.username !== newGuildMember.user.username check is unlikely to catch username edits. If alsoCheckUsernames is meant to react to username changes, add a userUpdate event handler (and map the updated user to the guild member) instead of relying on guildMemberUpdate.
| if (oldGuildMember.nickname === newGuildMember.nickname && oldGuildMember.user.username === newGuildMember.user.username) return; | |
| if (oldGuildMember.nickname === newGuildMember.nickname) return; |
| if (moduleConf.symbolWhitelist.length === 0) { | ||
| if (name.charAt(0).match(/^[a-zA-Z0-9]$/)) { | ||
| return name; | ||
| } else { | ||
| return await checkUsername(client, name.substring(1), isUsername); | ||
| } |
There was a problem hiding this comment.
checkUsername uses charAt(0) and substring(1), which operate on UTF-16 code units. This breaks the notion of “first character” for surrogate pairs / emoji (and makes it impossible to whitelist an emoji reliably). Consider iterating by Unicode code points/graphemes (e.g., [...name][0] / slicing by code points, or Intl.Segmenter if you need grapheme clusters).
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
as per Sukram2.0's suggestion
also added tabs in en.json...