Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ export const connect: () => Promise<WASocket> = 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 =
Expand Down Expand Up @@ -179,11 +187,6 @@ export const connect: () => Promise<WASocket> = async () => {
logger.debug('🔄 Conectando...');
break;
}

if (qr !== undefined) {
logger.debug('🔑 QR Code gerado');
qrcode.generate(qr, { small: true });
}
});

bot.ev.on('creds.update', saveCreds);
Expand Down