Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
778 B
3
Indexable
Never
bot.action('choose_db_anggur', async (ctx) => {
    const database = 'anggur';
    ctx.db = ctx.db || {};
    ctx.db.database = database;
    ctx.reply('Enter the user ID to search:');
});

bot.on('text', async (ctx) => {
    const database = (ctx.db && ctx.db.database) || 'lainnya';
    const db = await connectToMongoDB(database);
    const targetUserId = parseInt(ctx.message.text.trim(), 10);
    const userData = await db.collection('users').findOne({ _id: targetUserId });
    console.log(userData);
    if (userData) {
        ctx.reply(`User data:\nDatabase: ${database}\nTarget User ID: ${userData._id}\nUsername: ${userData.username}\n Status Premium: ${userData.user_premium}\n`);
    } else {
        ctx.reply('User data not found.');
    }
});
Leave a Comment