Answer the question
In order to leave comments, you need to log in
Why doesn't the check work?
if (msg.message.text.match('!kick')) {
if(await isAdmin(msg)) {
let playerid = msg.message.text
let findplayer = playerid.match(/\[id(\d+)/)[1];
let causes = playerid.match(/] (.+)/)[1];
if (findplayer && causes === ''){
messagesend('запрос неверный')
} else {
vk.call('messages.removeChatUser', {
chat_id: msg.message.peer_id - 2000000000,
user_id: findplayer
});
messagesend('🔫Был исключен vk.com/id' + findplayer + ' | Причина: ' + causes)
}
} else {
notmessage();
}
}
Answer the question
In order to leave comments, you need to log in
It should most likely be like this:
async function test() {
// ...
if (msg.message.text.startsWith('!kick')) {
if (await isAdmin(msg)) {
const str = msg.message.text;
const idStart = str.indexOf(' ');
const idEnd = str.indexOf(' ', idStart + 1);
const id = str.slice(idStart + 2, idEnd);
const reason = str.slice(idEnd + 1);
if ((idStart < 0) || (idEnd < 0) || (id.length === 0) || (reason.length === 0)) {
messagesend('Неверная команда.');
} else {
vk.call('messages.removeChatUser', {
chat_id: msg.message.peer_id - 2000000000,
user_id: id
});
messagesend(`🔫 Был исключен vk.com/${id} | Причина: ${reason}`);
}
} else {
notmessage();
}
}
// ...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question