Last active
November 3, 2025 23:02
-
-
Save Corex24/7884863f7a625d2c7dacca3799698fc3 to your computer and use it in GitHub Desktop.
๐ถ No description? ๐
Ohkay ohkay... Fast response powered by David Cyrilโs API โก๏ธ โ Made by Corex with ๐
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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.') | |
| } | |
| } | |
| ) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi