Skip to content

Commit d8271b1

Browse files
authored
Update api.js
1 parent a9b3127 commit d8271b1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

β€Žapi.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,22 @@ import axios from 'axios';
88
import moment from 'moment-timezone';
99

1010
/* Para agregar mΓ‘s APIs asegurate de poner global.apiname = ['APIKey'] */ /* By Skid πŸ€‘ */
11+
const ytdl = require('ytdl-core');
1112

13+
// Usa tu clave de API aquΓ­
14+
const API_KEY = 'AIzaSyDiapwiIPcUZG4_7wB0sCY4r1Tfi3fX3EM';
15+
16+
async function playCommand(url, chat) {
17+
if (!ytdl.validateURL(url)) {
18+
return chat.reply('Por favor, proporciona un enlace vΓ‘lido de YouTube.');
19+
}
20+
21+
const info = await ytdl.getInfo(url);
22+
const audioStream = ytdl(url, { filter: 'audioonly' });
23+
24+
// Enviar el audio al chat
25+
chat.sendMessage({ audio: audioStream, filename: `${info.videoDetails.title}.mp3` });
26+
}
1227
global.openai_key = 'sk-0';
1328
/* ObtΓ©n tu API Key en este enlace: https://platform.openai.com/account/api-keys */
1429

0 commit comments

Comments
Β (0)