From c994ae17679f65dc11edb5ac762fae8dc59dcd64 Mon Sep 17 00:00:00 2001 From: Miikka Virtanen Date: Fri, 30 Dec 2016 19:46:41 +0200 Subject: [PATCH] Safeguard against names with only special chars --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 675aae7..cfd456f 100644 --- a/index.js +++ b/index.js @@ -230,7 +230,8 @@ function getModmailChannel(user, allowCreate = true) { } else { if (! allowCreate) return Promise.resolve(null); - const cleanName = user.username.replace(/[^a-zA-Z0-9]/ig, '').toLowerCase(); + const cleanName = user.username.replace(/[^a-zA-Z0-9]/ig, '').toLowerCase().trim(); + if (cleanName === '') cleanName = 'unknown'; // If one is not found, create and cache it return modMailGuild.createChannel(`${cleanName}-${user.discriminator}`)