Advertisement
Profesar

Untitled

Dec 8th, 2021
23
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // inside chat.on(...
  2. const args = event.message.split(" ").filter(e => e.trim());
  3. // if your regex check passes
  4. if(regex){
  5. sw(event, chat,args)
  6. }
  7.  
  8. // outside chat.on(...)
  9. async function sw(event, chat, args) {
  10. 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|\"|\']*)+/;
  11. let url = args[1];
  12. if (!validLink.test(url)) return;
  13. try {
  14. const song = await axios.post(`https://songwhip.com/`, { url: url }).then(res => res.data);
  15. chat.say(event.channel, song.url);
  16. } catch (error) {
  17. chat.say(event.channel, error.response.data);
  18. }
  19. }
Advertisement
RAW Paste Data Copied
Advertisement