play
Aliases: Sem alias adicional
Preview da case pronta
case 'play': {
try {
if (!q || !q.trim())
return reply(`❌ Exemplo: ${prefix + command} nome da música`);
const yts = require("yt-search");
await reagir(from, "🎧");
const search = await yts(q);
if (!search || !search.videos || search.videos.length === 0)
return reply("❌ Não encontrei resultados.");
const video = search.videos[0];
const title = video.title;
const channel = video.author.name;
const duration = video.timestamp;
const thumbnail = video.thumbnail;
const url = video.url;
const cardUrl =
`https://tokito-apis.site/canvas/youtube?` +
`capa=${encodeURIComponent(thumbnail)}` +
`&titulo=${encodeURIComponent(title)}` +
`&canal=${encodeURIComponent(channel)}` +
`&duracao=${encodeURIComponent(duration)}` +
`&url=${encodeURIComponent(url)}`;
await tokito.sendMessage(
from,
{
image: { url: cardUrl },
caption:
`🎶 • ${title}\n` +
`👤 • ᴄᴀɴᴀʟ: ${channel}\n` +
`⏱️ • ᴅᴜʀᴀᴄ̧ᴀ̃ᴏ: ${duration}\n` +
`🔗 • ʟɪɴᴋ: ${url}`
},
{ quoted: selo }
);
let audioUrl =
`https://tokito-apis.site/api/youtube-audio?q=${encodeURIComponent(url)}&apikey=${API_KEY_TOKITO}`;
try {
await tokito.sendMessage(
from,
{
audio: { url: audioUrl },
mimetype: 'audio/mpeg',
ptt: false
},
{ quoted: selo }
);
} catch (err) {
audioUrl =
`https://tokito-apis.site/api/youtube-audio?q=${encodeURIComponent(`${title} ${channel}`)}&apikey=${API_KEY_TOKITO}`;
await tokito.sendMessage(
from,
{
audio: { url: audioUrl },
mimetype: 'audio/mpeg',
ptt: false
},
{ quoted: selo }
);
}
} catch (e) {
console.log(e);
reply("❌ Erro ao buscar o áudio.");
}
}
break;