-
-
Save Corex24/7884863f7a625d2c7dacca3799698fc3 to your computer and use it in GitHub Desktop.
| // Created by Corex with ๐ | |
| // github.com/Corex24 | |
| // | |
| // t.me/corex2410 | |
| const { bot } = require('../lib/') | |
| const fetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args)) | |
| bot( | |
| { | |
| pattern: 'cplay ?(.*)', | |
| type: 'music', | |
| desc: 'Play a song from YouTube by search term', | |
| }, | |
| async (message, match) => { | |
| if (!match) | |
| return await message.send('โ Please enter a song name.\nExample: `.cplay faded`') | |
| const api = `https://apis.davidcyriltech.my.id/play?query=${encodeURIComponent(match)}` | |
| try { | |
| const res = await fetch(api) | |
| const text = await res.text() | |
| let data | |
| // Safely parse JSON | |
| try { | |
| data = JSON.parse(text) | |
| } catch { | |
| console.error('โ JSON Parse Error:', text) | |
| return await message.send('โ Failed to read API response. Try again later.') | |
| } | |
| // Check structure | |
| if (data?.status === true && data?.result?.download_url) { | |
| const song = data.result | |
| // Send audio file | |
| await message.sendFromUrl(song.download_url, { mimetype: 'audio/mp4', ptt: false }, 'audio') | |
| // Song caption | |
| const caption = `๐ถ *${song.title || 'Unknown'}*\n๐บ *Views:* ${song.views || '-'}\nโฑ *Duration:* ${song.duration || '-'}\n๐ *Published:* ${song.published || '-'}\n๐ *URL:* ${song.video_url || '-'}\n\n_Made by Corex with ๐_` | |
| await message.send(caption) | |
| } else { | |
| console.log('โ ๏ธ Unexpected API data:', data) | |
| await message.send('โ No song found for your query.') | |
| } | |
| } catch (e) { | |
| console.error('CPLAY ERROR:', e) | |
| await message.send('โ An error occurred while processing your request.') | |
| } | |
| } | |
| ) |
๐๐ฟ๐ผ ๐ฐ๐ฎ๐ป ๐๐ผ๐ ๐บ๐ฎ๐ธ๐ฒ ๐๐ถ๐๐ฒ๐๐ฐ๐ผ๐ฟ๐ฒ ๐ฝ๐น๐๐ด๐ถ๐ป ๐ณ๐ผ๐ฟ ๐ณ๐ผ๐ผ๐๐ฏ๐ฎ๐น๐น ๐น๐ถ๐๐ฒ๐๐ฐ๐ผ๐ฟ๐ฒ ๐ฟ๐ฒ๐๐๐น๐๐. ๐๐ถ๐ธ๐ฒ ๐ณ๐ผ๐ฟ ๐ฝ๐ฟ๐ฒ๐บ๐ถ๐ฒ๐ฟ ๐น๐ฒ๐ฎ๐ด๐๐ฒ, ๐น๐ฎ๐น๐ถ๐ด๐ฎ ๐ฎ๐ป๐ฑ ๐ฐ๐ต๐ฎ๐บ๐ฝ๐ถ๐ผ๐ป๐ ๐น๐ฒ๐ฎ๐ด๐๐ฒ
https://gist.github.com/Corex24/7884863f7a625d2c7dacca3799698fc3
๐๐ฟ๐ผ ๐ฐ๐ฎ๐ป ๐๐ผ๐ ๐บ๐ฎ๐ธ๐ฒ ๐๐ถ๐๐ฒ๐๐ฐ๐ผ๐ฟ๐ฒ ๐ฝ๐น๐๐ด๐ถ๐ป ๐ณ๐ผ๐ฟ ๐ณ๐ผ๐ผ๐๐ฏ๐ฎ๐น๐น ๐น๐ถ๐๐ฒ๐๐ฐ๐ผ๐ฟ๐ฒ ๐ฟ๐ฒ๐๐๐น๐๐. ๐๐ถ๐ธ๐ฒ ๐ณ๐ผ๐ฟ ๐ฝ๐ฟ๐ฒ๐บ๐ถ๐ฒ๐ฟ ๐น๐ฒ๐ฎ๐ด๐๐ฒ, ๐น๐ฎ๐น๐ถ๐ด๐ฎ ๐ฎ๐ป๐ฑ ๐ฐ๐ต๐ฎ๐บ๐ฝ๐ถ๐ผ๐ป๐ ๐น๐ฒ๐ฎ๐ด๐๐ฒ
Hiii
Hi
https://gist.github.com/Corex24/7884863f7a625d2c7dacca3799698fc3