Remove BG Command

This commit is contained in:
lilyissillyyy
2025-09-07 00:22:49 -04:00
parent 1044b9e04a
commit 55534ba5f1
4 changed files with 61 additions and 2 deletions
+1
View File
@@ -37,6 +37,7 @@ GITHUB_ACCESS_TOKEN=
GOOGLE_KEY=
GOV_KEY=
IDIOT_URL=
REMOVEBG_KEY=
SAUCENAO_KEY=
SPOTIFY_KEY=
SPOTIFY_SECRET=
+5 -1
View File
@@ -70,6 +70,7 @@ Only if you want to use the DECTalk command.
* `GOOGLE_KEY` is your API key for Google, used for the YouTube Data API. You can get one [here](https://console.cloud.google.com/apis/dashboard). You must also [activate the YouTube Data API](https://console.cloud.google.com/marketplace/product/google/youtube.googleapis.com?q=search).
* `GOV_KEY` is your API key for NASA. You get get one [here](https://api.nasa.gov/).
* `IDIOT_URL` is a URL, ideally to the [Wikipedia page of an idiot](https://en.wikipedia.org/wiki/Donald_Trump). By default, it will reply with "_Stares at you._"
* `REMOVEBG_KEY` is your API key for remove.bg. You can get one [here](https://www.remove.bg/api).
* `SAUCENAO_KEY` is your API key for SauceNAO. Register, login, and click [here](https://saucenao.com/user.php?page=search-api) to get one.
* `SPOTIFY_KEY` and `SPOTIFY_SECRET` are your key and secret for the Spotify API. You can get one by [following these instructions](https://developer.spotify.com/documentation/web-api).
* `THECATAPI_KEY` is your API key for The Cat API. You can get one [here](https://thecatapi.com/).
@@ -101,7 +102,7 @@ Only if you want to use the DECTalk command.
18. Start Xiao up!
## Commands
Total: 518
Total: 519
### Utility:
@@ -458,6 +459,7 @@ Total: 518
* **police-tape:** Draws police tape over an image or a user's avatar.
* **rainbow:** Draws a rainbow over an image or a user's avatar.
* **rejected:** Draws a "rejected" stamp over an image or a user's avatar.
* **remove-bg:** Removes the background from an image.
* **resize:** Draws an image or a user's avatar resized to the size you want.
* **rotate:** Draws an image or a user's avatar but rotated a number of degrees.
* **sepia:** Draws an image or a user's avatar in sepia.
@@ -1223,6 +1225,8 @@ Total: 518
- [PNG Arts](https://www.pngarts.com/) ([Image](https://www.pngarts.com/explore/94078))
* **rejected:**
- [Clipart Library](http://clipart-library.com/) ([Image](http://clipart-library.com/clipart/Rejected-Stamp-Transparent.htm))
* **remove-bg:**
- [remove.bg](https://www.remove.bg/) ([API](https://www.remove.bg/api))
* **sip:**
- [CoolClips.com](http://search.coolclips.com/) ([Image](http://search.coolclips.com/m/vector/hand0007/Hands-holding-mug/))
* **sketch:**
+54
View File
@@ -0,0 +1,54 @@
const Command = require('../../framework/Command');
const { PermissionFlagsBits } = require('discord.js');
const request = require('node-superfetch');
const { REMOVEBG_KEY } = process.env;
module.exports = class RemoveBgCommand extends Command {
constructor(client) {
super(client, {
name: 'remove-bg',
aliases: ['remove-background'],
group: 'edit-image',
description: 'Removes the background from an image.',
clientPermissions: [PermissionFlagsBits.AttachFiles],
throttling: {
usages: 1,
duration: 120
},
credit: [
{
name: 'remove.bg',
url: 'https://www.remove.bg/',
reason: 'API',
reasonURL: 'https://www.remove.bg/api'
}
],
args: [
{
key: 'image',
type: 'image-or-avatar',
default: msg => msg.author.displayAvatarURL({ extension: 'png', size: 2048, forceStatic: true })
}
]
});
}
async run(msg, { image }) {
try {
const { body } = await request
.post('https://api.remove.bg/v1.0/removebg')
.set({ 'X-Api-Key': REMOVEBG_KEY })
.send({
size: 'auto',
image_url: image,
format: 'png'
});
return msg.say({ files: [{ attachment: body, name: 'remove-bg.png' }] });
} catch (err) {
if (err.status === 400) return msg.reply('Something is wrong with your image.');
if (err.status === 402) return msg.reply('Sorry! I\'m out of credits. Try again next month!');
if (err.status === 429) return msg.reply('Sorry, I\'m overloaded. Try again later!');
throw err;
}
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "155.2.3",
"version": "155.3.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {