Answer the question
In order to leave comments, you need to log in
How to display the answer not in the console, but in a line?
vk.updates.hear(/^(?:rcon)\s?([^]+)?/i, (message) => {
return rcon.connect().then(() => {
return rcon.send(`${message.$match[1]}`);
}).then(res => {
console.log(res);
}).then(() => {
return message.send(`ОТВЕТ СЮДА`);
return rcon.disconnect();
})
});
Answer the question
In order to leave comments, you need to log in
I don't get it either, but I'm thinking like this
vk.updates.hear(/^(?:rcon)\s?([^]+)?/i, (message) => {
return rcon.connect()
.then(() => {
return rcon.send(`${message.$match[1]}`);
})
.then((res) => {
console.log(res);
// После консоль лога сделать return
return res;
})
.then((res) => {
// Два return'a работать не будут. Нужно оставить что-то одно
message.send(res);
return rcon.disconnect();
});
});
vk.updates.hear(/^(?:rcon)\s?([^]+)?/i, (message) => {
return rcon.connect()
.then(() => rcon.send(`${message.$match[1]}`))
.then((res) => {
console.log(res);
message.send(res);
return rcon.disconnect();
});
});
Perhaps I did not understand the question, but maybe this will help.
let cachedMessage = '';
vk.updates.hear(/^(?:rcon)\s?([^]+)?/i, (message) => {
cachedMessage = message;
return rcon.connect().then(() => {
return rcon.send(`${message.$match[1]}`);
}).then(res => {
console.log(res);
}).then(() => {
return message.send(cachedMessage);
return rcon.disconnect();
})
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question