Untitled
unknown
javascript
3 years ago
1.0 kB
5
Indexable
const giphy = { baseURL: 'https://api.giphy.com/v1/gifs/', apiKey: '7IfGSmZdSFRLfxQaPcLtpQamsqj1ySOa', tag: 'monkey', type: 'random', rating: '' } let giphyURL = encodeURI( giphy.baseURL + giphy.type + '?api_key=' + giphy.apiKey + '&tag=' + giphy.tag + '&rating=' + giphy.rating ) https .get(giphyURL, resp => { let data = '' // A chunk of data has been received. resp.on('data', chunk => { data += chunk }) // The whole response has been received. Print out the result. resp.on('end', () => { var gif = JSON.parse(data) gif = gif.data.embed_url.split('/') gif = 'https://i.giphy.com/media/' + gif[4] + '/giphy-downsized-small.mp4' MessageMedia.fromUrl(gif, { unsafeMime: true }).then(media => { msg.reply(media, null, { sendVideoAsGif: true }) }) }) }) .on('error', err => { console.log('Error: ' + err.message) }) }
Editor is loading...