BugFix: Only initiate download on inactivity, not on collection stop.

master
masterhc 8 months ago
parent ab9392e530
commit d132846caf

@ -456,7 +456,7 @@ exports.torrent = (bot)=>
embed.addFields({name:req.params.name, value:" "},
{name:'Size', value:`${req.params.size/1024/1024}MB`},
{name:'From:', value:req.params.category});
let random = Random(5);
const random = Random(5);
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
@ -474,27 +474,27 @@ exports.torrent = (bot)=>
new ButtonBuilder()
.setCustomId('AproveLater'+random)
.setLabel('Aprove Later')
.setStyle(ButtonStyle.Success),
.setStyle(ButtonStyle.Secondary),
)
const filter = i => i.customId === 'Redirect'+random || i.customId === 'Remove'+random;
const filter = i => i.customId.includes(random)
let message = await user.send({embeds: [embed], components: [row] });
const collector = message.createMessageComponentCollector({ filter, time: 5*60000 });
const Cookie = await getCookie();
let manualStop = false;
collector.on('collect', async m =>
{
if(!Cookie) return
manualStop = true;
collector.stop();
m.deferUpdate();
let cookie = await getCookie();
if(!cookie) return
if(m.customId === 'Remove'+random)
if(m.customId.includes('Remove'))
{
await fetch("https://utorrent.wordfights.com/api/v2/torrents/delete", {
"headers": {
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
"cookie":cookie,
"cookie":Cookie,
},
"referrerPolicy": "same-origin",
"body": `hashes=${req.params.id}&deleteFiles=false`,
@ -504,11 +504,11 @@ exports.torrent = (bot)=>
});
return m.message.delete();
}
if(m.customId === 'AproveLater'+random) return
if(m.customId.includes('AproveLater')) return
await fetch("https://utorrent.wordfights.com/api/v2/torrents/setForceStart", {
"headers": {
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
"cookie": cookie,
"cookie": Cookie,
},
"body": `value=true&hashes=${req.params.id}`,
"method": "POST"
@ -517,10 +517,11 @@ exports.torrent = (bot)=>
collector.on('end', async ()=>
{
message.edit({ components: [] });
if(manualStop) return
await fetch("https://utorrent.wordfights.com/api/v2/torrents/setForceStart", {
"headers": {
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
"cookie": cookie,
"cookie": Cookie,
},
"body": `value=true&hashes=${req.params.id}`,
"method": "POST"

Loading…
Cancel
Save