Profesar

Songwhip API

Nov 29th, 2021 (edited)
773
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // songwhip
  2. export async function sw(event, chat, args) {
  3.   const validLink = /(https?:\/\/)?(?:[a-z0-9]*[\-\.])*(?:apple|spotify|youtube|youtu|bandcamp|tidal|pandora|napster|yandex|amazon|deezer|jiosaavn|audius|gaana|soundcloud|page)\.(?:com|co|link|be)(?:\/[^ |\n|\t|\"|\']*)+/;
  4.   let url = args[1];
  5.   if (!validLink.test(url)) return;
  6.   try {
  7.     const song = await axios.post(`https://songwhip.com/`, { url: url }).then(res => res.data);
  8.     await chat.say(event.channel, song.url);
  9.   } catch (error) {
  10.     console.log(error);
  11.     await chat.say(event.channel, error.response.data);
  12.   }
  13. }
RAW Paste Data