Skip to content

Added module name-list-cleaner#178

Open
hfgd123 wants to merge 1 commit intoScootKit:beta-discordjs14from
hfgd123:beta-discordjs14
Open

Added module name-list-cleaner#178
hfgd123 wants to merge 1 commit 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.

if (newName === guildMember.user.username) return;
} else return;
if (guildMember.guild.ownerId === guildMember.id) {
client.logger.error('[nicknames] ' + localize('name-list-cleaner', 'owner-cannot-be-renamed', {u: guildMember.user.username}))
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

The log prefix here is [nicknames] but the message is for the name-list-cleaner module. This makes operational debugging harder; switch the prefix/tag to [name-list-cleaner] for consistency with the rest of this file’s logging.

Suggested change
client.logger.error('[nicknames] ' + localize('name-list-cleaner', 'owner-cannot-be-renamed', {u: guildMember.user.username}))
client.logger.error('[name-list-cleaner] ' + localize('name-list-cleaner', 'owner-cannot-be-renamed', {u: guildMember.user.username}))

Copilot uses AI. Check for mistakes.
client.logger.error('[name-list-cleaner] ' + localize('name-list-cleaner', 'nickname-error', {u: guildMember.user.username, e: e}))
}
} else {
await guildMember.setNickname(null, localize('name-list-cleaner', 'nickname-reset', {u: guildMember.user.username}));
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

In the keepNickname === false branch, setNickname(null, ...) is awaited without error handling. Other nickname-changing code in this repo wraps setNickname in try/catch (or .catch) to avoid unhandled rejections when the bot lacks permissions / role hierarchy is too low; apply the same handling here.

Suggested change
await guildMember.setNickname(null, localize('name-list-cleaner', 'nickname-reset', {u: guildMember.user.username}));
try {
await guildMember.setNickname(null, localize('name-list-cleaner', 'nickname-reset', {u: guildMember.user.username}));
} catch (e) {
client.logger.error('[name-list-cleaner] ' + localize('name-list-cleaner', 'nickname-error', {u: guildMember.user.username, e: e}))
}

Copilot uses AI. Check for mistakes.
Comment on lines +34 to +41
if (name.length === 0) return 'INVALID NAME';
if (moduleConf.symbolWhitelist === []) {
if (name.charAt(0).match(/^[a-zA-Z0-9]$/)) {
return name;
} else {
return await checkUsername(client, name.substring(1));
}
} else if (!moduleConf.symbolWhitelist.includes(name.charAt(0)) && !moduleConf.isBlacklist) {
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

moduleConf.symbolWhitelist === [] will always be false in JS (array reference comparison). This breaks the intended “empty list” behavior (especially when isBlacklist is true). Use an emptiness check like Array.isArray(...) && symbolWhitelist.length === 0 (and ensure the empty-list behavior matches the config description).

Copilot uses AI. Check for mistakes.
Comment on lines +34 to +35
if (name.length === 0) return 'INVALID NAME';
if (moduleConf.symbolWhitelist === []) {
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

When the input name consists entirely of stripped characters, this returns the hard-coded string 'INVALID NAME', which would then be applied as a nickname. Consider returning null/'' and handling that in renameMember (e.g., reset nickname or skip) so the bot never sets a literal "INVALID NAME" nickname.

Suggested change
if (name.length === 0) return 'INVALID NAME';
if (moduleConf.symbolWhitelist === []) {
if (name.length === 0) return null;
if (!Array.isArray(moduleConf.symbolWhitelist) || moduleConf.symbolWhitelist.length === 0) {

Copilot uses AI. Check for mistakes.
"link": "https://github.com/hfgd123",
"scnxOrgID": "2"
},
"openSourceURL": "https://github.com/hfgd123/CustomDCBot/tree/main/modules/username-check",
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

openSourceURL points to modules/username-check, which doesn’t match this module’s name/path (modules/name-list-cleaner). Update it to the correct repository URL so metadata consumers can find the module’s source.

Suggested change
"openSourceURL": "https://github.com/hfgd123/CustomDCBot/tree/main/modules/username-check",
"openSourceURL": "https://github.com/hfgd123/CustomDCBot/tree/main/modules/name-list-cleaner",

Copilot uses AI. Check for mistakes.
} catch (e) {
client.logger.error('[name-list-cleaner] ' + localize('name-list-cleaner', 'nickname-error', {u: guildMember.user.username, e: e}))
}
} else {
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

If alsoCheckUsernames is enabled and keepNickname is false, this code will attempt setNickname(null, ...) even when the member already has no nickname (no-op but still an API call + audit log entry). Consider short-circuiting when guildMember.nickname === null in this branch to avoid unnecessary requests.

Suggested change
} else {
} else {
if (guildMember.nickname === null) {
return;
}

Copilot uses AI. Check for mistakes.
if (guildMember.nickname !== null) {
newName = await checkUsername(client, guildMember.nickname);
if (newName === guildMember.nickname) return;
} else if (moduleConf.alsoCheckUsername) {
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

moduleConf.alsoCheckUsername does not match the configuration key defined in this module's config schema (alsoCheckUsernames), so the username-check path will never run. Rename one side so the code reads the actual configured flag (and keep naming consistent across config + implementation).

Suggested change
} else if (moduleConf.alsoCheckUsername) {
} else if (moduleConf.alsoCheckUsernames) {

Copilot uses AI. Check for mistakes.
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.

1 participant

Comments