-
-
Save kajju027/95545169ed806585e13bb261a14a808d 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: 's ?(.*)', | |
| type: 'music', | |
| desc: 'Play a song from a search term', | |
| }, | |
| async (message, match) => { | |
| // No input message | |
| if (!match) | |
| return await message.send( | |
| 'โ Please enter a song name.\n\nExample: *.sonu Kiyu Ra MC ๐ฅน๐*' | |
| ) | |
| const api = `https://apis.davidcyriltech.my.id/play?query=${encodeURIComponent(match)}` | |
| try { | |
| const res = await fetch(api) | |
| const data = await res.json() | |
| if (!data.status || !data.result || !data.result.download_url) { | |
| return await message.send('โ No song found for your query.\n') | |
| } | |
| // ---------- STYLED CAPTION ---------- | |
| const caption = | |
| `๐ง *TITLE:* _${data.result.title || 'Unknown'}_\n\n` + | |
| `๐ *TOTAL VIEW:* ${data.result.views || '-'}\n\n` + | |
| `โณ *DURATION:* ${data.result.duration || '-'}\n\n` + | |
| `๐ง *PUBLISHED:* ${data.result.published || '-'}\n\n` + | |
| `> *แฎแดแดกแดสแดแด แดส ๊ถแดสแดษด แดแดษช ๐*` | |
| // ---------- SEND THUMBNAIL ---------- | |
| if (data.result.thumbnail) { | |
| await message.sendFromUrl( | |
| data.result.thumbnail, | |
| { caption }, | |
| 'image' | |
| ) | |
| } | |
| // ---------- SEND AUDIO ---------- | |
| await message.sendFromUrl( | |
| data.result.download_url, | |
| { mimetype: 'audio/mp4', ptt: false }, | |
| 'audio' | |
| ) | |
| } catch (err) { | |
| console.error(err) | |
| await message.send( | |
| 'โ An unexpected error occurred while processing your request.\nPlease try again later.' | |
| ) | |
| } | |
| } | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment