Remini / HDR

by Xshoptopup

15
Raw
case 'remini': {
    if (!quoted) return m.reply(`Reply to an image with caption ${prefix + command}`);
    if (!/image/.test(mime)) return m.reply('Only supports images');

    let media = await quoted.download();

    try {
        await xstbot.sendMessage(from, { text: 'Processing your image, please wait...' }, { quoted: m });

        if (!media) throw new Error('Failed to download media');

        const formData = new FormData();
        formData.append('file', media, {
            filename: 'image.jpg',
            contentType: 'image/jpeg'
        });

        const uploadResponse = await axios.post('https://cloudkuimages.guru/upload.php', formData, {
            headers: formData.getHeaders()
        });

        const imageUrl = uploadResponse.data?.result?.url;
        if (!imageUrl) throw new Error('Image URL not found in response');
         // Api remini ceknickname.my.id
        const res = await axios.get('https://api.ceknickname.my.id/api/remini', {
            params: { imageUrl }
        });

        const enhancedImageUrl = res.data.result.no_wm;

        await xstbot.sendMessage(from, {
            image: { url: enhancedImageUrl },
            caption: 'Berikut adalah gambar HD Anda!'
        }, { quoted: m });
    } catch (error) {
        console.error('Error enhancing image:', error);
        await xstbot.sendMessage(from, { text: 'Error enhancing image, please try again later.' }, { quoted: m });
    }
}
break;