diff --git a/controller/api.js b/controller/api.js index fc34533..2b8c704 100644 --- a/controller/api.js +++ b/controller/api.js @@ -493,11 +493,17 @@ exports.torrent = (bot)=> async function handleResponse(response) { - let headers = [...response.headers.entries()]; - headers = headers.filter(i=>i[0]=='set-cookie')[0][1] - return headers - - } + try { + let headers = [...response.headers.entries()]; + headers = headers.filter(i=>i[0]=='set-cookie')[0][1] + return headers + } catch (error) { + console.log(error) + return + } + + } + if(!cookie) return await fetch("https://utorrent.wordfights.com/api/v2/torrents/setForceStart", { "headers": { "content-type": "application/x-www-form-urlencoded; charset=UTF-8", @@ -505,12 +511,7 @@ exports.torrent = (bot)=> }, "body": `value=true&hashes=${req.params.id}`, "method": "POST" - }); - - - - - + }); }); collector.on('end', async ()=> {