From 2e1e009b4272495798313bd3bd61f258875c62e1 Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Mon, 24 Jun 2024 23:15:33 +0700 Subject: [PATCH] feat(bots/discord): add more fallbacks for decancering --- bots/discord/src/utils/discord/moderation.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bots/discord/src/utils/discord/moderation.ts b/bots/discord/src/utils/discord/moderation.ts index f306fea..0250676 100644 --- a/bots/discord/src/utils/discord/moderation.ts +++ b/bots/discord/src/utils/discord/moderation.ts @@ -52,7 +52,13 @@ export const cureNickname = async (member: GuildMember) => { .toString() .replace(/[^a-zA-Z0-9]/g, '') - if (!cured || !/^[a-zA-Z]/.test(cured)) cured = config.moderation?.cure?.defaultName ?? 'ReVanced member' + if (cured.length < 3 || !/^[a-zA-Z]/.test(cured)) + cured = + member.user.username.length >= 3 + ? member.user.username + : config.moderation?.cure?.defaultName ?? 'Server member' + + if (cured.toLowerCase() === name.toLowerCase()) return await member.setNickname(cured, 'Nickname cured') logger.log(`Cured nickname for ${member.user.tag} (${member.id}) from "${name}"`)