Compare commits

...

3 Commits

@ -27,23 +27,23 @@ class OwnedCommand extends Command {
if (args.member) {
if (args.member.id == this.client.user.id) {
if (args.member.id === this.client.user.id) {
return message.reply('You really thought you could own me?, pathetic...');
} else if (args.member.id == this.client.ownerID) {
} else if (args.member.id === this.client.ownerID) {
return message.reply('You really thought you could own him?, pathetic...');
} else if (args.member.id == '286054184623538177' || args.member.id == '172112210863194113') {
} else if (args.member.id === '286054184623538177' || args.member.id === '172112210863194113') {
owned = message.author;
}
if (ownedMessage == epicMessage[0]) {
if (ownedMessage === epicMessage[0]) {
return message.reply(ownedMessage);
}
return message.send(`${owned}, ${ownedMessage}`);
return message.channel.send(`${owned}, ${ownedMessage}`);
} else {
return message.send(ownedMessage);
return message.channel.send(ownedMessage);
}
}
}

@ -115,13 +115,23 @@ class DownloadCommand extends Command {
const params = new URLSearchParams();
params.append('url', args.link.href);
params.append('proxy', proxy[args.proxy].ip);
fetch(`${Hapi}/download`, {method: 'POST', body: params})
.then(async res => {
console.log(`status is ${res.status}`);
if (res.status !== 200) {
console.log('Status is not 200. Abort');
return message.channel.send('An error has occurred.');
if (args.proxy != null) {
args.proxy = args.proxy + 1;
} else {
args.proxy = 0;
args.proxyAuto = true;
}
if (!proxy[args.proxy]) return message.channel.send('`HTTP Error 429: Too Many Requests.`\nThe website you tried to download from probably has the bot blocked along with its proxy');
return this.client.commandHandler.runCommand(message, this.client.commandHandler.findCommand('download'), args);
}
if (res.headers.get('content-type') === 'application/json; charset=utf-8') { // If we receive JSON it mean it started compressing the video
@ -200,6 +210,7 @@ class DownloadCommand extends Command {
}
});
} else { // No Hapi server, let the bot download it
console.log('[Download] Hapi is not online.');
if (args.proxy && !args.proxyAuto) { // args.proxyAuto is only provided when the command is run after a error 429
args.proxy = args.proxy - 1;
if (!proxy[args.proxy]) args.proxy = 0;

@ -1,7 +1,7 @@
const { Command } = require('discord-akairo');
const captureWebsite = require('capture-website');
const os = require('os');
const fs = require('fs');
const { Hapi } = require('../../config.json');
const checkHapi = require('../../utils/checkHapi');
const fetch = require('node-fetch');
class screenshotCommand extends Command {
constructor() {
@ -12,7 +12,7 @@ class screenshotCommand extends Command {
args: [
{
id: 'url',
type: 'string',
type: 'url',
prompt: {
start: 'Please send a link of which website you want to take a screenshot of.',
retry: 'This does not look like an url, please try again.'
@ -33,15 +33,35 @@ class screenshotCommand extends Command {
}
async exec(message, args) {
let url = args.url;
if (!url.includes('http')) url = `http://${url}`;
if (url.includes('config.json') || url.includes('file://')) return message.channel.send('I don\'t think so');
if (args.url.href.includes('config.json') || args.url.href.includes('file://')) return message.channel.send('I don\'t think so');
let Embed = this.client.util.embed()
.setColor(message.member ? message.member.displayHexColor : 'NAVY')
.setTitle(url);
.setColor(message.member ? message.member.displayHexColor : 'NAVY');
let loadingmsg = await message.channel.send('Taking a screenshot <a:loadingmin:527579785212329984>');
const isHapiOnline = await checkHapi();
if (isHapiOnline) {
const params = new URLSearchParams();
params.append('url', args.url.href);
fetch(`${Hapi}/screenshot`, {method: 'POST', body: params})
.then(async res => {
console.log(res);
console.log(`Status is: ${res.status}`);
if (res.status === 200) {
let json = await res.json();
Embed.setImage(json.image);
Embed.setTitle(json.url);
await message.reply(Embed);
}
await loadingmsg.delete();
});
} else {
return message.reply('Hapi server is not online, try again later!');
}
/*
await captureWebsite.file(url, `${os.tmpdir()}/${message.id}.jpg`, {
type: 'jpeg',
headers: {
@ -63,6 +83,7 @@ class screenshotCommand extends Command {
return message.channel.send(Embed);
}
});
*/
}
}
module.exports = screenshotCommand;
Loading…
Cancel
Save