Safeguard against names with only special chars
parent
d616ecd957
commit
c994ae1767
3
index.js
3
index.js
|
@ -230,7 +230,8 @@ function getModmailChannel(user, allowCreate = true) {
|
||||||
} else {
|
} else {
|
||||||
if (! allowCreate) return Promise.resolve(null);
|
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
|
// If one is not found, create and cache it
|
||||||
return modMailGuild.createChannel(`${cleanName}-${user.discriminator}`)
|
return modMailGuild.createChannel(`${cleanName}-${user.discriminator}`)
|
||||||
|
|
Loading…
Reference in New Issue