Add proxy options
Signed-off-by: loicbersier <loic.bersier1@gmail.com>
This commit is contained in:
parent
eb28545cbd
commit
43a78f9939
1 changed files with 38 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
||||||
const { Command } = require('discord-akairo');
|
const { Command } = require('discord-akairo');
|
||||||
|
const { proxy } = require('../../config.json');
|
||||||
const fetch = require('node-fetch');
|
const fetch = require('node-fetch');
|
||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
@ -8,6 +9,18 @@ class PetitTubeCommand extends Command {
|
||||||
aliases: ['petittube', 'pt'],
|
aliases: ['petittube', 'pt'],
|
||||||
category: 'fun',
|
category: 'fun',
|
||||||
clientPermissions: ['SEND_MESSAGES', 'ATTACH_FILES'],
|
clientPermissions: ['SEND_MESSAGES', 'ATTACH_FILES'],
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
id: 'proxy',
|
||||||
|
match: 'option',
|
||||||
|
flag: ['--proxy'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'listproxy',
|
||||||
|
match: 'flag',
|
||||||
|
flag: ['--listproxy', '--proxylist']
|
||||||
|
}
|
||||||
|
],
|
||||||
description: {
|
description: {
|
||||||
content: 'Fetch a video from https://petittube.com/',
|
content: 'Fetch a video from https://petittube.com/',
|
||||||
usage: '',
|
usage: '',
|
||||||
|
@ -16,7 +29,25 @@ class PetitTubeCommand extends Command {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(message) {
|
async exec(message, args) {
|
||||||
|
if (args.listproxy) {
|
||||||
|
let proxys = [];
|
||||||
|
|
||||||
|
let i = 0;
|
||||||
|
proxy.forEach(proxy => {
|
||||||
|
i++;
|
||||||
|
proxys.push(`[${i}] ${ proxy.hideip ? '[IP HIDDEN]' : proxy.ip.substring(0, proxy.ip.length - 5)} - ${proxy.country}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
const Embed = this.client.util.embed()
|
||||||
|
.setColor(message.member ? message.member.displayHexColor : 'NAVY')
|
||||||
|
.setTitle('List of available proxy')
|
||||||
|
.setDescription(proxys.join('\n'))
|
||||||
|
.setFooter('You can help me get more proxy by either donating to me or providing a proxy for me');
|
||||||
|
|
||||||
|
return message.channel.send(Embed);
|
||||||
|
}
|
||||||
|
|
||||||
const response = await fetch('https://petittube.com/');
|
const response = await fetch('https://petittube.com/');
|
||||||
const body = await response.text();
|
const body = await response.text();
|
||||||
|
|
||||||
|
@ -24,7 +55,12 @@ class PetitTubeCommand extends Command {
|
||||||
|
|
||||||
const url = $('iframe')[0].attribs.src;
|
const url = $('iframe')[0].attribs.src;
|
||||||
|
|
||||||
this.client.commandHandler.runCommand(message, this.client.commandHandler.findCommand('download'), { link: new URL(url), proxy: 1, spoiler: !message.channel.nsfw, caption: message.channel.nsfw ? '' : 'Video might be NSFW as always, be careful!'});
|
if (args.proxy) {
|
||||||
|
args.proxy = args.proxy -1;
|
||||||
|
if (!proxy[args.proxy]) args.proxy = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.client.commandHandler.runCommand(message, this.client.commandHandler.findCommand('download'), { link: new URL(url), proxy: args.proxy, spoiler: !message.channel.nsfw, caption: message.channel.nsfw ? '' : 'Video might be NSFW as always, be careful!'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = PetitTubeCommand;
|
module.exports = PetitTubeCommand;
|
Loading…
Reference in a new issue