chomens-bot-js/util/containsIllegalCharacters.js

19 lines
559 B
JavaScript
Raw Permalink Normal View History

2022-11-15 21:33:16 -05:00
/**
* character allowed in mc chat
* @param {String} character the character
* @return {boolean} allowed
*/
2022-11-27 02:35:28 -05:00
function isAllowedCharacter (character) {
return character !== '\xa7' && 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-11-27 02:35:28 -05:00
function containsIllegalCharacters (string) {
for (let i = 0; i < string.length; i++) if (!isAllowedCharacter(string[i])) return true
2022-08-18 21:39:59 -04:00
}
module.exports = { containsIllegalCharacters, isAllowedCharacter }