chomens-bot-js/util/containsIllegalCharacters.js

20 lines
587 B
JavaScript
Raw Normal View History

2022-08-18 21:39:59 -04:00
/* eslint-disable max-len */
2022-11-15 21:33:16 -05:00
/**
* character allowed in mc chat
* @param {String} character the character
* @return {boolean} allowed
*/
2022-08-18 21:39:59 -04:00
function isAllowedCharacter(character) {
return character !== '\xa7' && character >= ' ' && character !== '\x7f';
2022-08-18 21:39:59 -04:00
}
2022-11-15 21:33:16 -05:00
/**
* mc chat check if contains illegal chars.
* @param {String} string the string
* @return {boolean} if contains then true else false
*/
2022-08-18 21:39:59 -04:00
function containsIllegalCharacters(string) {
for (let i = 0; i < string.length; i++) if (!isAllowedCharacter(string[i])) return true;
}
module.exports = {containsIllegalCharacters};