UNPKG

rickroll-detector

Version:

``` npm i rickroll-detector ```

43 lines (41 loc) 1.34 kB
const request = require('request'); module.exports = { isRick: async function isRick(input) { try{ if (!input) throw new Error('No Input provided!'); if (typeof input !== 'string') throw new Error( `Expected a string! For example - "https://youtube.com/user/rickastley" but recieved ${typeof input}` ); if(!input.startsWith("http")){ let body3 = input.toLowerCase(); if ( body3.includes('rick roll') || body3.includes('rick astley') || body3.includes('never gonna') ) { return 'Yep, This is a RickRoll!'; } else { return "Nope, This ain't a RickRoll"; } }else{ request(input), function (error, response, body) { console.error('error:', error); let body2 = body.toString(); let body3 = body2.toLowerCase(); if ( body3.includes('rick roll') || body3.includes('rick astley') || body3.includes('never gonna') ) { return 'Yep, This is a RickRoll!'; } else { return "Nope, This ain't a RickRoll"; } }; } }catch(err){ console.log(err) } }