diff --git a/src/connection.ts b/src/connection.ts index 524ba46..d2a8bad 100644 --- a/src/connection.ts +++ b/src/connection.ts @@ -98,6 +98,14 @@ export const connect: () => Promise = async () => { bot.ev.on('connection.update', async (update) => { const { connection, lastDisconnect, qr } = update; + + // Handle QR code first, before processing connection state + if (qr !== undefined) { + console.log('\n๐Ÿ”‘ QR Code gerado! Escaneie o cรณdigo abaixo:\n'); + qrcode.generate(qr, { small: true }); + logger.info('๐Ÿ”‘ QR Code exibido no terminal'); + } + switch (connection) { case 'close': { const statusCode = @@ -179,11 +187,6 @@ export const connect: () => Promise = async () => { logger.debug('๐Ÿ”„ Conectando...'); break; } - - if (qr !== undefined) { - logger.debug('๐Ÿ”‘ QR Code gerado'); - qrcode.generate(qr, { small: true }); - } }); bot.ev.on('creds.update', saveCreds);