Skip to content

Commit f522e4d

Browse files
committed
Add new commands, add new fonts, restructure slash commands
- Add new commands -> Add `.caption`, `.trim` - Restructure slash commands, as in add more top-level commands to fix character limits
1 parent b3d8c34 commit f522e4d

38 files changed

+581
-298
lines changed

src/api/endpoints.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ export const Api = Object.freeze({
7979
'/image/manipulation/blur',
8080
IMAGE_MANIPULATION_BLURPLE:
8181
'/image/manipulation/blurple',
82+
IMAGE_MANIPULATION_CAPTION:
83+
'/image/manipulation/caption',
8284
IMAGE_MANIPULATION_CIRCLE:
8385
'/image/manipulation/circle',
8486
IMAGE_MANIPULATION_DEEPFRY:
@@ -193,6 +195,8 @@ export const Api = Object.freeze({
193195
'/image/tools/resize',
194196
IMAGE_TOOLS_ROTATE:
195197
'/image/tools/rotate',
198+
IMAGE_TOOLS_TRIM:
199+
'/image/tools/trim',
196200

197201
INFO_DISCORD:
198202
'/info/discord',

src/api/index.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,14 @@ export async function imageManipulationBlurple(
456456
}
457457

458458

459+
export async function imageManipulationCaption(
460+
context: RequestContext,
461+
options: RestOptions.ImageManipulationCaption,
462+
) {
463+
return raw.imageManipulationCaption(context, options);
464+
}
465+
466+
459467
export async function imageManipulationCircle(
460468
context: RequestContext,
461469
options: RestOptions.ImageManipulationCircle,
@@ -807,13 +815,6 @@ export async function imageToolsBackgroundRemove(
807815
return raw.imageToolsBackgroundRemove(context, options);
808816
}
809817

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

818819
export async function imageToolsObjectRemove(
819820
context: RequestContext,
@@ -895,6 +896,13 @@ export async function imageToolsRotate(
895896
}
896897

897898

899+
export async function imageToolsTrim(
900+
context: RequestContext,
901+
options: RestOptions.ImageBaseOptions,
902+
) {
903+
return raw.imageToolsTrim(context, options);
904+
}
905+
898906

899907
export async function putGuildSettings(
900908
context: RequestContext,

src/api/raw.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,26 @@ export async function imageManipulationBlurple(
848848
}
849849

850850

851+
export async function imageManipulationCaption(
852+
context: RequestContext,
853+
options: RestOptions.ImageManipulationCaption,
854+
): Promise<Response> {
855+
const query = {
856+
font: options.font,
857+
text: options.text,
858+
url: options.url,
859+
};
860+
return request(context, {
861+
dataOnly: false,
862+
query,
863+
route: {
864+
method: HTTPMethods.POST,
865+
path: Api.IMAGE_MANIPULATION_CAPTION,
866+
},
867+
});
868+
}
869+
870+
851871
export async function imageManipulationCircle(
852872
context: RequestContext,
853873
options: RestOptions.ImageManipulationCircle,
@@ -1670,6 +1690,7 @@ export async function imageToolsBackgroundRemove(
16701690
): Promise<Response> {
16711691
const query = {
16721692
model: options.model,
1693+
trim: options.trim,
16731694
url: options.url,
16741695
};
16751696
return request(context, {
@@ -1876,6 +1897,24 @@ export async function imageToolsRotate(
18761897
}
18771898

18781899

1900+
export async function imageToolsTrim(
1901+
context: RequestContext,
1902+
options: RestOptions.ImageBaseOptions,
1903+
): Promise<Response> {
1904+
const query = {
1905+
url: options.url,
1906+
};
1907+
return request(context, {
1908+
dataOnly: false,
1909+
query,
1910+
route: {
1911+
method: HTTPMethods.POST,
1912+
path: Api.IMAGE_TOOLS_TRIM,
1913+
},
1914+
});
1915+
}
1916+
1917+
18791918
export async function putGuildSettings(
18801919
context: RequestContext,
18811920
guildId: string,

src/api/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ export namespace RestOptions {
175175

176176
export interface ImageBackgroundRemoveOptions extends ImageBaseOptions {
177177
model?: string,
178+
trim?: boolean,
178179
}
179180

180181
export interface ImageObjectRemoveOptions extends ImageBaseOptions {
@@ -205,6 +206,11 @@ export namespace RestOptions {
205206
scale?: number,
206207
}
207208

209+
export interface ImageManipulationCaption extends ImageBaseOptions {
210+
font?: ImageMemeFonts,
211+
text: string,
212+
}
213+
208214
export interface ImageManipulationCircle extends ImageBaseOptions {
209215
scale?: number,
210216
}

src/commands/interactions/slash/image/gif/glitch.ts renamed to src/commands/interactions/slash/image-gif/glitch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Interaction } from 'detritus-client';
22

3-
import { Formatter } from '../../../../../utils';
3+
import { Formatter } from '../../../../utils';
44

5-
import { BaseInteractionImageCommandOption } from '../../../basecommand';
5+
import { BaseInteractionImageCommandOption } from '../../basecommand';
66

77

88
export const COMMAND_NAME = 'glitch';
Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
1-
import { BaseInteractionCommandOptionGroup } from '../../../basecommand';
2-
3-
import { ImageGifGlitchCommand } from './glitch';
4-
import { ImageGifMagikCommand } from './magik';
5-
import { ImageGifReverseCommand } from './reverse';
6-
import { ImageGifSeeSawCommand } from './seesaw';
7-
import { ImageGifSpeedCommand } from './speed';
8-
9-
10-
export class ImageGifGroupCommand extends BaseInteractionCommandOptionGroup {
11-
description = '.';
12-
name = 'gif';
13-
14-
constructor() {
15-
super({
16-
options: [
17-
new ImageGifGlitchCommand(),
18-
new ImageGifMagikCommand(),
19-
new ImageGifReverseCommand(),
20-
new ImageGifSeeSawCommand(),
21-
new ImageGifSpeedCommand(),
22-
],
23-
});
24-
}
25-
}
1+
import { Permissions } from 'detritus-client/lib/constants';
2+
3+
import { BaseSlashCommand } from '../../basecommand';
4+
5+
import { ImageGifGlitchCommand } from './glitch';
6+
import { ImageGifMagikCommand } from './magik';
7+
import { ImageGifReverseCommand } from './reverse';
8+
import { ImageGifSeeSawCommand } from './seesaw';
9+
import { ImageGifSpeedCommand } from './speed';
10+
import { ImageSpinCommand } from './spin';
11+
12+
13+
export default class ImageGifGroupCommand extends BaseSlashCommand {
14+
description = 'Image Gif Commands';
15+
name = 'i-gif';
16+
17+
constructor() {
18+
super({
19+
permissions: [Permissions.ATTACH_FILES],
20+
options: [
21+
new ImageGifGlitchCommand(),
22+
new ImageGifMagikCommand(),
23+
new ImageGifReverseCommand(),
24+
new ImageGifSeeSawCommand(),
25+
new ImageGifSpeedCommand(),
26+
new ImageSpinCommand(),
27+
],
28+
});
29+
}
30+
}

src/commands/interactions/slash/image/gif/magik.ts renamed to src/commands/interactions/slash/image-gif/magik.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Interaction } from 'detritus-client';
22

3-
import { Formatter } from '../../../../../utils';
3+
import { Formatter } from '../../../../utils';
44

5-
import { BaseInteractionImageCommandOption } from '../../../basecommand';
5+
import { BaseInteractionImageCommandOption } from '../../basecommand';
66

77

88
export const COMMAND_NAME = 'magik';
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { Interaction } from 'detritus-client';
2-
3-
import { Formatter } from '../../../../../utils';
4-
5-
import { BaseInteractionImageCommandOption } from '../../../basecommand';
6-
7-
8-
export const COMMAND_NAME = 'reverse';
9-
10-
export class ImageGifReverseCommand extends BaseInteractionImageCommandOption {
11-
description = 'Reverse an Animated Image';
12-
metadata = {
13-
id: Formatter.Commands.ImageGifReverse.COMMAND_ID,
14-
};
15-
name = COMMAND_NAME;
16-
17-
async run(context: Interaction.InteractionContext, args: Formatter.Commands.ImageGifReverse.CommandArgs) {
18-
return Formatter.Commands.ImageGifReverse.createMessage(context, args);
19-
}
20-
}
1+
import { Interaction } from 'detritus-client';
2+
3+
import { Formatter } from '../../../../utils';
4+
5+
import { BaseInteractionImageCommandOption } from '../../basecommand';
6+
7+
8+
export const COMMAND_NAME = 'reverse';
9+
10+
export class ImageGifReverseCommand extends BaseInteractionImageCommandOption {
11+
description = 'Reverse an Animated Image';
12+
metadata = {
13+
id: Formatter.Commands.ImageGifReverse.COMMAND_ID,
14+
};
15+
name = COMMAND_NAME;
16+
17+
async run(context: Interaction.InteractionContext, args: Formatter.Commands.ImageGifReverse.CommandArgs) {
18+
return Formatter.Commands.ImageGifReverse.createMessage(context, args);
19+
}
20+
}
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { Interaction } from 'detritus-client';
2-
3-
import { Formatter } from '../../../../../utils';
4-
5-
import { BaseInteractionImageCommandOption } from '../../../basecommand';
6-
7-
8-
export const COMMAND_NAME = 'seesaw';
9-
10-
export class ImageGifSeeSawCommand extends BaseInteractionImageCommandOption {
11-
description = 'SeeSaw an Animated Image, add a reversed copy of itself at the end of it';
12-
metadata = {
13-
id: Formatter.Commands.ImageGifSeeSaw.COMMAND_ID,
14-
};
15-
name = COMMAND_NAME;
16-
17-
async run(context: Interaction.InteractionContext, args: Formatter.Commands.ImageGifSeeSaw.CommandArgs) {
18-
return Formatter.Commands.ImageGifSeeSaw.createMessage(context, args);
19-
}
20-
}
1+
import { Interaction } from 'detritus-client';
2+
3+
import { Formatter } from '../../../../utils';
4+
5+
import { BaseInteractionImageCommandOption } from '../../basecommand';
6+
7+
8+
export const COMMAND_NAME = 'seesaw';
9+
10+
export class ImageGifSeeSawCommand extends BaseInteractionImageCommandOption {
11+
description = 'SeeSaw an Animated Image, add a reversed copy of itself at the end of it';
12+
metadata = {
13+
id: Formatter.Commands.ImageGifSeeSaw.COMMAND_ID,
14+
};
15+
name = COMMAND_NAME;
16+
17+
async run(context: Interaction.InteractionContext, args: Formatter.Commands.ImageGifSeeSaw.CommandArgs) {
18+
return Formatter.Commands.ImageGifSeeSaw.createMessage(context, args);
19+
}
20+
}
Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
import { Interaction } from 'detritus-client';
2-
3-
import { Formatter } from '../../../../../utils';
4-
5-
import { BaseInteractionImageCommandOption } from '../../../basecommand';
6-
7-
8-
export const COMMAND_NAME = 'speed';
9-
10-
export class ImageGifSpeedCommand extends BaseInteractionImageCommandOption {
11-
description = 'Edit an Animated Image\'s Speed';
12-
metadata = {
13-
id: Formatter.Commands.ImageGifSpeed.COMMAND_ID,
14-
};
15-
name = COMMAND_NAME;
16-
17-
constructor() {
18-
super({
19-
options: [
20-
{name: 'speed', description: 'milliseconds'},
21-
],
22-
});
23-
}
24-
25-
async run(context: Interaction.InteractionContext, args: Formatter.Commands.ImageGifSpeed.CommandArgs) {
26-
return Formatter.Commands.ImageGifSpeed.createMessage(context, args);
27-
}
28-
}
1+
import { Interaction } from 'detritus-client';
2+
3+
import { Formatter } from '../../../../utils';
4+
5+
import { BaseInteractionImageCommandOption } from '../../basecommand';
6+
7+
8+
export const COMMAND_NAME = 'speed';
9+
10+
export class ImageGifSpeedCommand extends BaseInteractionImageCommandOption {
11+
description = 'Edit an Animated Image\'s Speed';
12+
metadata = {
13+
id: Formatter.Commands.ImageGifSpeed.COMMAND_ID,
14+
};
15+
name = COMMAND_NAME;
16+
17+
constructor() {
18+
super({
19+
options: [
20+
{name: 'speed', description: 'milliseconds'},
21+
],
22+
});
23+
}
24+
25+
async run(context: Interaction.InteractionContext, args: Formatter.Commands.ImageGifSpeed.CommandArgs) {
26+
return Formatter.Commands.ImageGifSpeed.createMessage(context, args);
27+
}
28+
}

0 commit comments

Comments
 (0)