code/ttp

schedule Created January 17, 2026

maker
code
const nexray = require('api-nexray');
const config = require("@config");
const { sendImageAsSticker } = require("@lib/exif");

async function handle(sock, messageInfo) {
    const { remoteJid, message, content, isQuoted, prefix, command } = messageInfo;

    try {
        const text = content && content.trim() !== '' ? content : isQuoted?.text ?? null;

        // Validasi input konten
        if (!text) {
            await sock.sendMessage(remoteJid, {
                text: `_⚠️ Format Penggunaan:_ \n\n_💬 Contoh:_ _*${prefix + command} halo*_`
            }, { quoted: message });
            return; // Hentikan eksekusi jika tidak ada konten
        }

        // Kirimkan pesan loading dengan reaksi emoji
        await sock.sendMessage(remoteJid, {
            react: { text: "⏰", key: message.key }
        });

        // Buat instance API dan ambil data dari endpoin
        const response = await nexray.getBuffer('/maker/ttp', { text: text });

               // Kirimkan stiker hasil quote
               const options = {
                packname: config.sticker_packname,
                author: config.sticker_author
            };
            await sendImageAsSticker(sock, remoteJid, response, options, message);

    } catch (error) {
        // Tangani kesalahan dan kirimkan pesan error ke pengguna
        const errorMessage = `Maaf, terjadi kesalahan saat memproses permintaan Anda. Coba lagi nanti.\n\nError: ${error.message}`;
        await sock.sendMessage(remoteJid, {
            text: errorMessage
        }, { quoted: message });
    }
}

module.exports = {
    handle,
    Commands    : ['ttp'],
    OnlyPremium : false,
    OnlyOwner   : false,
    limitDeduction  : false
};