Merge pull request #62 from Eniamza/master

Fix : Use RegEx based splitting instead of space character
This commit is contained in:
Jeremy Kauffman 2021-04-20 16:17:47 -04:00 committed by GitHub
commit eaa5f32c09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View file

@ -23,11 +23,11 @@ bot.on('message', msg => {
//check if message is a command
if (msg.author.id !== bot.user.id && msg.content.startsWith(botConfig.prefix)) {
console.log(`treating ${msg.content} from ${msg.author} as command`);
let cmdTxt = msg.content.split(' ')[0].substring(botConfig.prefix.length);
let cmdTxt = msg.content.split(/ +/)[0].substring(botConfig.prefix.length);
let suffix = msg.content.substring(cmdTxt.length + botConfig.prefix.length + 1); //add one for the ! and one for the space
if (msg.mentions.has(bot.user)) {
try {
cmdTxt = msg.content.split(' ')[1];
cmdTxt = msg.content.split(/ +/)[1];
suffix = msg.content.substring(bot.user.toString().length + cmdTxt.length + botConfig.prefix.length + 1);
} catch (e) {
//no command

View file

@ -35,7 +35,7 @@ exports.tip = {
let tipper = msg.author.id,
words = msg.content
.trim()
.split(' ')
.split(/ +/)
.filter(function(n) {
return n !== '';
}),
@ -68,7 +68,7 @@ exports.multitip = {
let tipper = msg.author.id.replace('!', ''),
words = msg.content
.trim()
.split(' ')
.split(/ +/)
.filter(function(n) {
return n !== '';
}),
@ -93,7 +93,7 @@ exports.roletip = {
let tipper = msg.author.id.replace('!', ''),
words = msg.content
.trim()
.split(' ')
.split(/ +/)
.filter(function(n) {
return n !== '';
}),