Skip to content

Commit 91559cd

Browse files
committed
Added .object remove and /i objects remove
Fixed minor bug with background remove prefixed command class name
1 parent 1a4fa21 commit 91559cd

File tree

20 files changed

+401
-195
lines changed

20 files changed

+401
-195
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
2-
/lib
2+
/lib
3+
config.json
File renamed without changes.

package-lock.json

Lines changed: 109 additions & 185 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
"dependencies": {
1111
"@sentry/node": "^6.4.1",
1212
"chrono-node": "^2.3.8",
13-
"detritus-client": "^0.17.0-beta.10",
14-
"detritus-rest": "^0.9.0-beta.4",
13+
"detritus-client": "^0.17.0-beta.11",
1514
"emoji-aware": "^3.0.5",
1615
"juration": "^0.1.1",
1716
"moment": "^2.29.1",
1817
"moment-duration-format": "^2.3.2",
1918
"moment-timezone": "^0.5.32",
2019
"redis": "^3.1.2",
20+
"typescript": "^4.6.4",
2121
"undici": "^5.1.1"
2222
},
2323
"devDependencies": {

src/api/endpoints.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import { Tools } from 'detritus-utils';
44
export enum Domains {
55
CDN = 'https://cdn.notsobot.com',
66
BETA = 'https://beta.notsobot.com',
7-
LOCALHOST = 'http://localhost',
7+
LOCALHOST = 'http://localhost:8888',
88
STABLE = 'https://notsobot.com',
99
}
1010

1111
export const Api = Object.freeze({
12-
URL: Domains.BETA,
12+
URL: Domains.LOCALHOST,
1313
URL_PUBLIC: Domains.BETA,
14-
PATH: '/api',
14+
PATH: '',
1515

1616
AUDIO_TOOLS_CONVERT:
1717
'/audio/tools/convert',
@@ -173,6 +173,8 @@ export const Api = Object.freeze({
173173

174174
IMAGE_TOOLS_BACKGROUND_REMOVE:
175175
'/image/tools/background/remove',
176+
IMAGE_TOOLS_OBJECT_REMOVE:
177+
'/image/tools/object/remove',
176178
IMAGE_TOOLS_CONVERT:
177179
'/image/tools/convert',
178180
IMAGE_TOOLS_CROP:

src/api/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,13 @@ export async function imageToolsBackgroundRemove(
807807
return raw.imageToolsBackgroundRemove(context, options);
808808
}
809809

810+
export async function imageToolsObjectRemove(
811+
context: RequestContext,
812+
options: RestOptions.ImageObjectRemoveOptions,
813+
) {
814+
return raw.imageToolsObjectRemove(context, options);
815+
}
816+
810817

811818
export async function imageToolsConvert(
812819
context: RequestContext,

src/api/raw.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,6 +1680,25 @@ export async function imageToolsBackgroundRemove(
16801680
}
16811681

16821682

1683+
export async function imageToolsObjectRemove(
1684+
context: RequestContext,
1685+
options: RestOptions.ImageObjectRemoveOptions,
1686+
): Promise<Response> {
1687+
const query = {
1688+
label: options.object,
1689+
url: options.url,
1690+
};
1691+
return request(context, {
1692+
dataOnly: false,
1693+
query,
1694+
route: {
1695+
method: HTTPMethods.POST,
1696+
path: Api.IMAGE_TOOLS_OBJECT_REMOVE,
1697+
},
1698+
});
1699+
}
1700+
1701+
16831702
export async function imageToolsConvert(
16841703
context: RequestContext,
16851704
options: RestOptions.ImageToolsConvert,

src/api/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ export namespace RestOptions {
177177
model?: string,
178178
}
179179

180+
export interface ImageObjectRemoveOptions extends ImageBaseOptions {
181+
object?: string,
182+
}
183+
180184
export interface ImageCreateRetrowave {
181185
background?: number,
182186
line1?: string,

src/bot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const cluster = new ClusterClient('', {
114114
const notSoCommandBot = new NotSoCommandClient(cluster, {
115115
activateOnEdits: true,
116116
mentionsEnabled: true,
117-
prefix: '.',
117+
prefix: ',',
118118
ratelimits: [
119119
{duration: 60000, limit: 50, type: 'guild'},
120120
{duration: 5000, limit: 5, type: 'channel'},

src/commandclient.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@ import { Command, CommandClient } from 'detritus-client';
33
import { GuildAllowlistTypes, GuildBlocklistTypes, GuildDisableCommandsTypes } from './constants';
44
import GuildSettingsStore from './stores/guildsettings';
55
import UserStore from './stores/users';
6+
import { Endpoints } from './api';
67

78

89
export class NotSoCommandClient extends CommandClient {
910
async onCommandCheck(context: Command.Context, command: Command.Command) {
1011
if (context.user.isClientOwner) {
1112
return true;
13+
} else if (Endpoints.Api.URL == Endpoints.Domains.LOCALHOST) {
14+
return false;
1215
}
16+
1317
const user = await UserStore.getOrFetch(context, context.userId);
1418
if (!user || user.blocked) {
1519
return false;

0 commit comments

Comments
 (0)