Skip to content

Added module name-list-cleaner#178

Open
hfgd123 wants to merge 7 commits intoScootKit:beta-discordjs14from
hfgd123:beta-discordjs14
Open

Added module name-list-cleaner#178
hfgd123 wants to merge 7 commits intoScootKit:beta-discordjs14from
hfgd123:beta-discordjs14

Conversation

@hfgd123
Copy link
Contributor

@hfgd123 hfgd123 commented Feb 15, 2026

as per Sukram2.0's suggestion
also added tabs in en.json...

as per Sukram2.0's suggestion
also added tabs in en.json...
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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-cleaner module metadata, configuration schema, and event handlers.
  • Implements renameMember / checkUsername logic to compute a cleaned nickname (or reset nickname depending on config).
  • Updates locales/en.json formatting and adds name-list-cleaner locale 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.

@SCDerox
Copy link
Member

SCDerox commented Feb 27, 2026

Hi, quickly checking in, any updates on this?

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@hfgd123
Copy link
Contributor Author

hfgd123 commented Feb 27, 2026

Currently working through the suggestions. I didn't get a notification when Copilot answered 😅

hfgd123 and others added 3 commits February 27, 2026 13:26
- 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>
@SCDerox
Copy link
Member

SCDerox commented Feb 27, 2026

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:

  • Please disclose whether Generative Large Language Models ("Generative AI", e.g. Coplilot) were used and to what extent to write this code. In addition, please confirm that you have reviewed and tested any generated code thoroughly. For details, please review our AI Policy.
  • This branch has conflicts. Please ensure that no conflicts exist with the beta-discordjs14 branch.

@hfgd123
Copy link
Contributor Author

hfgd123 commented Feb 27, 2026

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

Copy link

Copilot AI left a comment

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 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.

Comment on lines +2 to +3
renameMember = async function (client, guildMember) {
let newName;
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

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(…)).

Copilot uses AI. Check for mistakes.
Comment on lines +49 to +55
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]$/)) {
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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)) {

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you want it to accept anything else, you can whitelist it, ig

Copy link
Member

Choose a reason for hiding this comment

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

imagine whitelisting every chinese character

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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;
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
if (oldGuildMember.nickname === newGuildMember.nickname && oldGuildMember.user.username === newGuildMember.user.username) return;
if (oldGuildMember.nickname === newGuildMember.nickname) return;

Copilot uses AI. Check for mistakes.
Comment on lines +48 to +53
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);
}
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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