Skip to content

Commit d8c46ff

Browse files
committed
Add new crop commands and rework b1
1 parent 2047942 commit d8c46ff

File tree

23 files changed

+418
-30
lines changed

23 files changed

+418
-30
lines changed

src/api/endpoints.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ export const Api = Object.freeze({
179179
'/image/tools/convert',
180180
IMAGE_TOOLS_CROP:
181181
'/image/tools/crop',
182+
IMAGE_TOOLS_CROP_CIRCLE:
183+
'/image/tools/crop/circle',
184+
IMAGE_TOOLS_CROP_TWITTER_HEX:
185+
'/image/tools/crop/twitter-hex',
182186
IMAGE_TOOLS_GIF_REVERSE:
183187
'/image/tools/gif/reverse',
184188
IMAGE_TOOLS_GIF_SEE_SAW:

src/api/index.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,14 @@ export async function imageToolsObjectRemove(
815815
}
816816

817817

818+
export async function imageToolsObjectRemove(
819+
context: RequestContext,
820+
options: RestOptions.ImageObjectRemoveOptions,
821+
) {
822+
return raw.imageToolsObjectRemove(context, options);
823+
}
824+
825+
818826
export async function imageToolsConvert(
819827
context: RequestContext,
820828
options: RestOptions.ImageToolsConvert,
@@ -831,6 +839,22 @@ export async function imageToolsCrop(
831839
}
832840

833841

842+
export async function imageToolsCropCircle(
843+
context: RequestContext,
844+
options: RestOptions.ImageToolsCropCircle,
845+
) {
846+
return raw.imageToolsCropCircle(context, options);
847+
}
848+
849+
850+
export async function imageToolsCropTwitterHex(
851+
context: RequestContext,
852+
options: RestOptions.ImageToolsCropTwitterHex,
853+
) {
854+
return raw.imageToolsCropTwitterHex(context, options);
855+
}
856+
857+
834858
export async function imageToolsGifReverse(
835859
context: RequestContext,
836860
options: RestOptions.ImageBaseOptions,

src/api/raw.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,6 +1741,44 @@ export async function imageToolsCrop(
17411741
}
17421742

17431743

1744+
export async function imageToolsCropCircle(
1745+
context: RequestContext,
1746+
options: RestOptions.ImageToolsCropCircle,
1747+
): Promise<Response> {
1748+
const query = {
1749+
background: options.background,
1750+
url: options.url,
1751+
};
1752+
return request(context, {
1753+
dataOnly: false,
1754+
query,
1755+
route: {
1756+
method: HTTPMethods.POST,
1757+
path: Api.IMAGE_TOOLS_CROP_CIRCLE,
1758+
},
1759+
});
1760+
}
1761+
1762+
1763+
export async function imageToolsCropTwitterHex(
1764+
context: RequestContext,
1765+
options: RestOptions.ImageToolsCropTwitterHex,
1766+
): Promise<Response> {
1767+
const query = {
1768+
background: options.background,
1769+
url: options.url,
1770+
};
1771+
return request(context, {
1772+
dataOnly: false,
1773+
query,
1774+
route: {
1775+
method: HTTPMethods.POST,
1776+
path: Api.IMAGE_TOOLS_CROP_TWITTER_HEX,
1777+
},
1778+
});
1779+
}
1780+
1781+
17441782
export async function imageToolsGifReverse(
17451783
context: RequestContext,
17461784
options: RestOptions.ImageBaseOptions,

src/api/types.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,14 @@ export namespace RestOptions {
272272
size?: string,
273273
}
274274

275+
export interface ImageToolsCropCircle extends ImageBaseOptions {
276+
background?: boolean,
277+
}
278+
279+
export interface ImageToolsCropTwitterHex extends ImageBaseOptions {
280+
background?: boolean,
281+
}
282+
275283
export interface ImageToolsGifSpeed extends ImageBaseOptions {
276284
loop?: boolean,
277285
speed: number,
@@ -838,6 +846,7 @@ export namespace RestResponsesRaw {
838846
spoiler: boolean,
839847
spoiler_id: null | number,
840848
tag: null | string,
849+
thumbnail: string,
841850
url: string,
842851
width: number,
843852
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Interaction } from 'detritus-client';
2+
3+
import { Formatter } from '../../../../utils';
4+
5+
import { BaseInteractionCommandOption } from '../../basecommand';
6+
7+
8+
export const COMMAND_NAME = 'b1';
9+
10+
export class B1Command extends BaseInteractionCommandOption {
11+
description = 'Cool B1 Emoji';
12+
metadata = {
13+
id: Formatter.Commands.FunB1.COMMAND_ID,
14+
};
15+
name = COMMAND_NAME;
16+
17+
async run(context: Interaction.InteractionContext, args: Formatter.Commands.FunB1.CommandArgs) {
18+
return Formatter.Commands.FunB1.createMessage(context, args);
19+
}
20+
}

src/commands/interactions/slash/fun/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Permissions } from 'detritus-client/lib/constants';
22

33
import { BaseSlashCommand } from '../../basecommand';
44

5+
import { B1Command } from './b1';
56
import { BadMemeCommand } from './badmeme';
67

78

@@ -13,6 +14,7 @@ export default class FunGroupCommand extends BaseSlashCommand {
1314
super({
1415
permissions: [Permissions.ATTACH_FILES],
1516
options: [
17+
new B1Command(),
1618
new BadMemeCommand(),
1719
],
1820
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +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 = 'crop-circle';
9+
10+
export class ImageToolsCropCircleCommand extends BaseInteractionImageCommandOption {
11+
description = 'Crop out a circle from an Image';
12+
metadata = {
13+
id: Formatter.Commands.ImageToolsCropCircle.COMMAND_ID,
14+
};
15+
name = COMMAND_NAME;
16+
17+
async run(context: Interaction.InteractionContext, args: Formatter.Commands.ImageToolsCropCircle.CommandArgs) {
18+
return Formatter.Commands.ImageToolsCropCircle.createMessage(context, args);
19+
}
20+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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 = 'crop-nft';
9+
10+
export class ImageToolsCropNFTCommand extends BaseInteractionImageCommandOption {
11+
description = 'Crop out a Twitter NFT Hex from an Image';
12+
metadata = {
13+
id: Formatter.Commands.ImageToolsCropNFT.COMMAND_ID,
14+
};
15+
name = COMMAND_NAME;
16+
17+
constructor() {
18+
super({
19+
options: [
20+
{
21+
name: 'background',
22+
description: 'Include a dark background (default: False)',
23+
type: Boolean,
24+
},
25+
],
26+
});
27+
}
28+
29+
async run(context: Interaction.InteractionContext, args: Formatter.Commands.ImageToolsCropNFT.CommandArgs) {
30+
return Formatter.Commands.ImageToolsCropNFT.createMessage(context, args);
31+
}
32+
}

src/commands/interactions/slash/image/tools/crop.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { BaseInteractionImageCommandOption } from '../../../basecommand';
88
export const COMMAND_NAME = 'crop';
99

1010
export class ImageToolsCropCommand extends BaseInteractionImageCommandOption {
11-
description = 'Crop an Image';
11+
description = 'Crop an Image automatically';
1212
metadata = {
1313
id: Formatter.Commands.ImageToolsCrop.COMMAND_ID,
1414
};

src/commands/interactions/slash/image/tools/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { BaseInteractionCommandOptionGroup } from '../../../basecommand';
22

33
import { ImageToolsConvertCommand } from './convert';
44
import { ImageToolsCropCommand } from './crop';
5+
import { ImageToolsCropCircleCommand } from './crop-circle';
6+
import { ImageToolsCropNFTCommand } from './crop-nft';
57
import { ImageJPEGCommand } from './jpeg';
68
import { ImageToolsResizeCommand } from './resize';
79
import { ImageSharpenCommand } from './sharpen';
@@ -16,6 +18,8 @@ export class ImageToolsGroupCommand extends BaseInteractionCommandOptionGroup {
1618
options: [
1719
new ImageToolsConvertCommand(),
1820
new ImageToolsCropCommand(),
21+
new ImageToolsCropCircleCommand(),
22+
new ImageToolsCropNFTCommand(),
1923
new ImageJPEGCommand(),
2024
new ImageToolsResizeCommand(),
2125
new ImageSharpenCommand(),

0 commit comments

Comments
 (0)