Skip to content

npm init -y npm install @whiskeysockets/baileys fluent-ffmpeg qrcode axios fs-extra #123

Description

@daffajagomlbb-creator

const { default: makeWASocket, useMultiFileAuthState, DisconnectReason, fetchLatestBaileysVersion } = require('@whiskeysockets/baileys');
const pino = require('pino');
const fs = require('fs');
const qrcode = require('qrcode-terminal');

let botName = "DF Store";

async function startBot() {
const { state, saveCreds } = await useMultiFileAuthState('auth_info');
const { version } = await fetchLatestBaileysVersion();

const sock = makeWASocket({
    auth: state,
    printQRInTerminal: true,
    logger: pino({ level: 'silent' }),
    version,
    browser: [botName, "Chrome", "4.0.0"],
});

sock.ev.on('connection.update', (update) => {
    const { connection, lastDisconnect, qr } = update;
    
    if(qr){
        qrcode.generate(qr, {small: true});
    }

    if(connection === 'close') {
        if(lastDisconnect.error.output.statusCode !== DisconnectReason.loggedOut) {
            startBot();
        }
    } else if(connection === 'open') {
        console.log(`✅ Bot ${botName} Terhubung!`);
    }
});

sock.ev.on('messages.upsert', async ({ messages }) => {
    const m = messages[0];
    if(!m.message) return;
    
    const text = m.message.conversation || m.message.extendedTextMessage?.text || '';
    const from = m.key.remoteJid;

    // Command sederhana
    if(text.toLowerCase() === '.menu') {
        sock.sendMessage(from, { text: `Selamat datang di *DF Store*\nSemua fitur sudah unlocked!\n\nKetik .help untuk melihat semua menu.` });
    }
});

sock.ev.on('creds.update', saveCreds);

}

startBot();

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions