From a53071c20647820cba02674d911237f707a9d700 Mon Sep 17 00:00:00 2001 From: defnotken Date: Mon, 8 Sep 2025 19:43:35 -0500 Subject: [PATCH] make lower limit 3 characters. add forbidden words. --- .../Discord/MareWizardModule.Vanity.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/LightlessSyncServer/LightlessSyncServices/Discord/MareWizardModule.Vanity.cs b/LightlessSyncServer/LightlessSyncServices/Discord/MareWizardModule.Vanity.cs index c926bc4..917dafc 100644 --- a/LightlessSyncServer/LightlessSyncServices/Discord/MareWizardModule.Vanity.cs +++ b/LightlessSyncServer/LightlessSyncServices/Discord/MareWizardModule.Vanity.cs @@ -92,13 +92,22 @@ public partial class LightlessWizardModule var desiredVanityUid = modal.DesiredVanityUID; using var db = await GetDbContext().ConfigureAwait(false); bool canAddVanityId = !db.Users.Any(u => u.UID == modal.DesiredVanityUID || u.Alias == modal.DesiredVanityUID); + var forbiddenWords = new[] { "null", "nil" }; - Regex rgx = new(@"^[_\-a-zA-Z0-9]{5,15}$", RegexOptions.ECMAScript); + Regex rgx = new(@"^[_\-a-zA-Z0-9]{3,15}$", RegexOptions.ECMAScript); if (!rgx.Match(desiredVanityUid).Success) { eb.WithColor(Color.Red); eb.WithTitle("Invalid Vanity UID"); - eb.WithDescription("A Vanity UID must be between 5 and 15 characters long and only contain the letters A-Z, numbers 0-9, dashes (-) and underscores (_)."); + eb.WithDescription("A Vanity UID must be between 3 and 15 characters long and only contain the letters A-Z, numbers 0-9, dashes (-) and underscores (_)."); + cb.WithButton("Cancel", "wizard-vanity", ButtonStyle.Secondary, emote: new Emoji("❌")); + cb.WithButton("Pick Different UID", "wizard-vanity-uid-set:" + uid, ButtonStyle.Primary, new Emoji("💅")); + } + else if (forbiddenWords.Contains(desiredVanityUid.Trim().ToLowerInvariant())) + { + eb.WithColor(Color.Red); + eb.WithTitle("Invalid Vanity UID"); + eb.WithDescription("You cannot use 'Null' or 'Nil' (any case) as a Vanity UID. Please pick a different one."); cb.WithButton("Cancel", "wizard-vanity", ButtonStyle.Secondary, emote: new Emoji("❌")); cb.WithButton("Pick Different UID", "wizard-vanity-uid-set:" + uid, ButtonStyle.Primary, new Emoji("💅")); }