forked from Supositware/Haha-Yes
remove.bg
This commit is contained in:
parent
9838e624ad
commit
188aff48d3
1 changed files with 46 additions and 0 deletions
46
commands/utility/removebg.js
Normal file
46
commands/utility/removebg.js
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
const { Command } = require('discord-akairo');
|
||||||
|
const { removebgAPI } = require('../../config.json');
|
||||||
|
const removd = require('removd');
|
||||||
|
const os = require('os');
|
||||||
|
|
||||||
|
class removebgCommand extends Command {
|
||||||
|
constructor() {
|
||||||
|
super('removebg', {
|
||||||
|
aliases: ['removebg'],
|
||||||
|
category: 'utility',
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
id: 'image',
|
||||||
|
type: 'string'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
description: {
|
||||||
|
content: 'Remove the background from the image you send using remove.bg',
|
||||||
|
usage: '',
|
||||||
|
examples: ['']
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async exec(message, args) {
|
||||||
|
let Attachment = (message.attachments).array();
|
||||||
|
let url = args.image;
|
||||||
|
if (Attachment[0] && !args.image) {
|
||||||
|
url = Attachment[0].url;
|
||||||
|
}
|
||||||
|
const outputFile = `${os.tmpdir()}/rempvebg.png`;
|
||||||
|
const done = await removd.url({
|
||||||
|
apikey: removebgAPI,
|
||||||
|
destination: outputFile,
|
||||||
|
source: url
|
||||||
|
});
|
||||||
|
if (done && !done.error) {
|
||||||
|
return message.channel.send({files: [outputFile]});
|
||||||
|
} else {
|
||||||
|
console.error(done);
|
||||||
|
return message.channel.send('Oh no! an error just occured!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = removebgCommand;
|
Loading…
Reference in a new issue