Transliterate non-ascii names for channel names properly
parent
1dc21880e2
commit
77b4ed856d
File diff suppressed because it is too large
Load Diff
|
@ -13,7 +13,8 @@
|
|||
"humanize-duration": "^3.10.0",
|
||||
"mime": "^1.3.4",
|
||||
"moment": "^2.17.1",
|
||||
"public-ip": "^2.0.1"
|
||||
"public-ip": "^2.0.1",
|
||||
"transliteration": "^1.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^3.9.1"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const Eris = require('eris');
|
||||
const transliterate = require('transliteration');
|
||||
const utils = require('./utils');
|
||||
const jsonDb = require('./jsonDb');
|
||||
const config = require('../config');
|
||||
|
@ -69,8 +70,9 @@ function getForUser(bot, user, allowCreate = true, originalMessage = null) {
|
|||
if (! allowCreate) return null;
|
||||
|
||||
// Channel names are particularly picky about what characters they allow...
|
||||
let cleanName = user.username.replace(/[^a-zA-Z0-9]/ig, '').toLowerCase().trim();
|
||||
let cleanName = transliterate.slugify(user.username);
|
||||
if (cleanName === '') cleanName = 'unknown';
|
||||
cleanName = cleanName.slice(0, 95); // Make sure the discrim fits
|
||||
|
||||
const channelName = `${cleanName}-${user.discriminator}`;
|
||||
|
||||
|
|
Loading…
Reference in New Issue