Answer the question
In order to leave comments, you need to log in
How to make a time limit per team?
vk.updates.hear(/^(?:ping)\s?([^]+)?/i, async (message) => {
if (!message.$match[1]) {
return message.send(`⚠ Вы не указали IP!\n Например: 127.0.0.0:25565`);
}
axios.get(`https://api.mcsrvstat.us/1/${message.$match[1]}`).then(res => {
if(res.data && res.data.players) {
let playerCount = res.data.players.online || 0
let playerMax = res.data.players.max || 0
let playerList = res.data.players.list || 'Нет игроков онлайн'
if(res.data && res.data.version) {
let version = res.data.version || 'Неизвестна'
if(res.data && res.data.motd.clean) {
let motd = res.data.motd.clean || 'Нет названия'
if(res.data && res.data.software) {
let core = res.data.software || 'Ядро неизвестно'
return message.send (` ${motd}:\n Версия: ${version}\n♂ Игроков: ${playerCount}/${playerMax} ${playerList}\n Ядро: ${core}`)
}
}
}
}else message.send(`⚠ Неверный ip адрес!\n Либо информация о нём недоступна.`);
}).catch(err => console.log('api.mcsrvstat.us ошибка:', err))
});
updates.startPolling()
.then(() => {
console.log(`Ping started!`);
})
Answer the question
In order to leave comments, you need to log in
let can_do_commands = true;
......
can_do_commands = false;
setTimeout("can_do_commands = true", 60000);
you can create an object, the keys of which will be the identifiers of users who have a restriction on sending
, then in the body of the command handler you need to add a check
if (!limits[message.senderId]) {
limits[message.senderId] = true;
setTimeout(() => {
delete limits[message.senderId];
}, 60000);
// отправляем сообщение
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question