new messages and more security when making stickers
This commit is contained in:
@@ -3,27 +3,33 @@ import { botMsg } from "../utils/botMsg.js";
|
||||
let jogoAtivo = null;
|
||||
|
||||
export function iniciarJogo() {
|
||||
jogoAtivo = Math.floor(Math.random()*100)+1;
|
||||
return jogoAtivo;
|
||||
jogoAtivo = Math.floor(Math.random() * 100) + 1;
|
||||
return jogoAtivo;
|
||||
}
|
||||
|
||||
export function pararJogo() {
|
||||
jogoAtivo = null;
|
||||
jogoAtivo = null;
|
||||
}
|
||||
|
||||
export async function processarJogo(msg, chat) {
|
||||
if (!jogoAtivo) return;
|
||||
if (!jogoAtivo) return;
|
||||
|
||||
const tentativa = msg.body.trim();
|
||||
if (!/^\d+$/.test(tentativa)) return;
|
||||
const tentativa = msg.body.trim();
|
||||
if (!/^\d+$/.test(tentativa)) return;
|
||||
|
||||
const num = parseInt(tentativa);
|
||||
if (num === jogoAtivo) {
|
||||
await msg.reply(botMsg(`Acertou! Número: ${jogoAtivo}`));
|
||||
pararJogo();
|
||||
} else if (num > jogoAtivo) {
|
||||
await chat.sendMessage(botMsg("Menor."));
|
||||
} else {
|
||||
await chat.sendMessage(botMsg("Maior."));
|
||||
}
|
||||
const num = parseInt(tentativa);
|
||||
|
||||
if (num === jogoAtivo) {
|
||||
await msg.reply(botMsg(
|
||||
`🎉 *Acertou!* O número era ${jogoAtivo}!\n\n` +
|
||||
"Use `!adivinhação começar` para jogar de novo."
|
||||
));
|
||||
pararJogo();
|
||||
} else if (num < 1 || num > 100) {
|
||||
await msg.reply(botMsg("⚠️ Digite um número entre 1 e 100."));
|
||||
} else if (num > jogoAtivo) {
|
||||
await chat.sendMessage(botMsg("📉 Tente um número *menor*!"));
|
||||
} else {
|
||||
await chat.sendMessage(botMsg("📈 Tente um número *maior*!"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user