make lower limit 3 characters. add forbidden words. #4
@@ -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("💅"));
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ public partial class LightlessWizardModule : InteractionModuleBase
|
||||
public string Title => "Set Vanity UID";
|
||||
|
||||
[InputLabel("Set your Vanity UID")]
|
||||
[ModalTextInput("vanity_uid", TextInputStyle.Short, "5-15 characters, underscore, dash", 5, 15)]
|
||||
[ModalTextInput("vanity_uid", TextInputStyle.Short, "3-15 characters, underscore, dash", 3, 15)]
|
||||
public string DesiredVanityUID { get; set; }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user