Cari code tersebut di whatsapp.js
sock[token].ev.on('connection.update', async (update) => {
lalu rubah code tersebut sampai code
}
});
ke code ini
sock[token].ev.on('connection.update', async (update) => {
const { connection, lastDisconnect, qr } = update;
if (qr) {
try {
const url = await QRCode.toDataURL(qr);
qrcode[token] = url;
socket?.emit('qrcode', { token, data: url, message: 'Scan this QR code with your WhatsApp' });
} catch (err) {
console.error('QR Code generation failed:', err);
}
}
if (connection === 'close') {
const disconnectError = lastDisconnect?.error;
if (disconnectError instanceof Boom &&
(disconnectError.output.statusCode === 403 || disconnectError.output.statusCode === 428)) {
setStatus(token, 'Disconnect');
console.log(`Connection closed with status code ${disconnectError.output.statusCode}. You are logged out.`);
socket?.emit('message', { token, message: `Connection closed with status code ${disconnectError.output.statusCode}. You are logged out.` });
await clearConnection(token);
clearInterval(reconnectInterval);
reconnectInterval = null;
} else {
const shouldReconnect = disconnectError instanceof Boom && disconnectError.output.statusCode !== DisconnectReason.loggedOut;
console.log('Connection closed due to', lastDisconnect?.error, 'Reconnecting:', shouldReconnect);
if (shouldReconnect) {
if (!reconnectInterval) {
reconnectInterval = setInterval(() => attemptConnection(), 10000);
}
} else {
setStatus(token, 'Disconnect');
console.log('Connection closed. You are logged out.');
socket?.emit('message', { token, message: 'Connection closed. You are logged out.' });
await clearConnection(token);
clearInterval(reconnectInterval);
reconnectInterval = null;
}
}
} else if (connection === 'open') {
setStatus(token, 'Connected');
console.log('Connected successfully!');
const userId = `${sock[token].user.id.split(':')[0]}@s.whatsapp.net`;
const ppUrl = await getPpUrl(token, userId);
socket?.emit('connection-open', { token, user: sock[token].user, ppUrl });
delete qrcode[token];
delete pairingCode[token];
clearInterval(reconnectInterval);
reconnectInterval = null;
}
});
menambahkan status Disconnect jika terdapat error 403 dan 428 (itu adalah code error banned/logout mendadak karna app unofficial dari whatsapp)
jika script bawaan dari mamang magd, jika logout atau di banned, status tidak berubah. saya hanya mengubah sedikit, yang disconnect saya barusan ngeblast dan beberapa mokad nomor nya