Answer the question
In order to leave comments, you need to log in
Commands are not displayed, how to fix it?
Hello, I'm making a bot for VK, I made a blacklist system for words and the bot broke)
Help, please. The commands stopped working, but when he sees these words, he displays a message.
const {VK, Keyboard, MessageContext } = require('vk-io');
const vk = new VK();
const {updates} = vk;
const fs = require("fs");
vk.setOptions({
token: '', // токен группы
apiMode: 'parallel',
pollingGroupId:
});
vk.updates.on('message', (context) => {
let blacklisted = ['lettuce', 'geyporno', 'привет']
let foundInText = false;
for (var i in blacklisted){
if (context.text.toLowerCase().includes(blacklisted[i].toLowerCase())) foundInText = true;
}
if (foundInText){
context.send('Вам вынесено предупреждение за мат. Старайтесь общаться более культурно, перечитайте правила беседы, иначе придется с вами попрощаться.');
}
});
vk.updates.hear(/hello/i, context => (
context.send('World!')
));
vk.updates.hear(/^(?:Информация|Выговоры)$/i, (message) => {
return message.send(` Таблица пиздюлей:
Ренат - 1
Макс - 1`);
});
const catsPurring = [
'http://liferussian.ru/vk/test.mp3'
];
vk.updates.hear('Помощь', async (context) => {
await context.send(`
Мои команнды :
/naxuy - послать говноеда
Информация | Выговоры - тут все янсо
А дальше хз что, ок?
`);
});
vk.updates.hear('/naxuy', async (context) => {
const link = catsPurring[Math.floor(Math.random() * catsPurring.length)];
await Promise.all([
context.send('Подожди, не много,сучка'),
context.sendAudioMessage(link)
]);
});
vk.updates.start().catch(console.error);
Answer the question
In order to leave comments, you need to log in
It seems to me that any word sent to the bot goes under vk.updates.on('message', (context).....
and therefore any other word that you write Help or any other command of yours simply does not get to check other words.
I think you will have to redo the message filtering logic a bit.
Maybe I'm wrong)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question