Skip to content

Commit cb3d797

Browse files
committed
Added .e2p and .e2e
1 parent cd5d3f6 commit cb3d797

File tree

15 files changed

+174
-23
lines changed

15 files changed

+174
-23
lines changed

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010
"dependencies": {
1111
"@sentry/node": "^6.4.1",
1212
"chrono-node": "^2.3.8",
13-
"detritus-client": "^0.17.0-beta.8",
14-
"detritus-client-rest": "^0.11.0-beta.3",
13+
"detritus-client": "^0.17.0-beta.10",
14+
"detritus-rest": "^0.9.0-beta.4",
1515
"emoji-aware": "^3.0.5",
1616
"juration": "^0.1.1",
1717
"moment": "^2.29.1",
1818
"moment-duration-format": "^2.3.2",
1919
"moment-timezone": "^0.5.32",
20-
"redis": "^3.1.2"
20+
"redis": "^3.1.2",
21+
"undici": "^5.1.1"
2122
},
2223
"devDependencies": {
2324
"@types/moment-duration-format": "^2.2.2",

src/api/endpoints.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ export const Api = Object.freeze({
125125
'/image/manipulation/mirror-top',
126126
IMAGE_MANIPULATION_PAPER:
127127
'/image/manipulation/paper',
128+
IMAGE_MANIPULATION_PIX2PIX:
129+
'/image/manipulation/pix2pix',
128130
IMAGE_MANIPULATION_PIXELATE:
129131
'/image/manipulation/pixelate',
130132
IMAGE_MANIPULATION_RAIN:

src/api/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,14 @@ export async function imageManipulationPaper(
640640
}
641641

642642

643+
export async function imageManipulationPix2Pix(
644+
context: RequestContext,
645+
options: RestOptions.ImageManipulationPix2Pix,
646+
) {
647+
return raw.imageManipulationPix2Pix(context, options);
648+
}
649+
650+
643651
export async function imageManipulationPixelate(
644652
context: RequestContext,
645653
options: RestOptions.ImageManipulationPixelate,

src/api/raw.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,25 @@ export async function imageManipulationPaper(
12801280
}
12811281

12821282

1283+
export async function imageManipulationPix2Pix(
1284+
context: RequestContext,
1285+
options: RestOptions.ImageManipulationPix2Pix,
1286+
): Promise<Response> {
1287+
const query = {
1288+
model: options.model,
1289+
url: options.url,
1290+
};
1291+
return request(context, {
1292+
dataOnly: false,
1293+
query,
1294+
route: {
1295+
method: HTTPMethods.POST,
1296+
path: Api.IMAGE_MANIPULATION_PIX2PIX,
1297+
},
1298+
});
1299+
}
1300+
1301+
12831302
export async function imageManipulationPixelate(
12841303
context: RequestContext,
12851304
options: RestOptions.ImageManipulationPixelate,

src/api/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ export namespace RestOptions {
247247
top: string,
248248
}
249249

250+
export interface ImageManipulationPix2Pix extends ImageBaseOptions {
251+
model: string,
252+
}
253+
250254
export interface ImageManipulationPixelate extends ImageBaseOptions {
251255
pixelWidth?: number,
252256
}

src/commands/prefixed/image/deepfry.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,9 @@ import { Formatter } from '../../../utils';
66
import { BaseImageCommand } from '../basecommand';
77

88

9-
export interface CommandArgsBefore {
10-
scale?: number,
11-
url?: null | string,
12-
}
13-
149
export const COMMAND_NAME = 'deepfry';
1510

16-
export default class DeepfryCommand extends BaseImageCommand<Formatter.Commands.ImageDeepfry.CommandArgs> {
11+
export default class DeepfryCommand extends BaseImageCommand {
1712
constructor(client: CommandClient) {
1813
super(client, {
1914
name: COMMAND_NAME,

src/commands/prefixed/image/e2e.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { Command, CommandClient } from 'detritus-client';
2+
3+
import { CommandCategories } from '../../../constants';
4+
import { Formatter } from '../../../utils';
5+
6+
import { BaseImageCommand } from '../basecommand';
7+
8+
9+
export const COMMAND_NAME = 'e2e';
10+
11+
export default class E2ECommand extends BaseImageCommand {
12+
constructor(client: CommandClient) {
13+
super(client, {
14+
name: COMMAND_NAME,
15+
16+
aliases: ['edges2emoji'],
17+
metadata: {
18+
category: CommandCategories.IMAGE,
19+
description: 'Edges to Emoji',
20+
examples: [
21+
COMMAND_NAME,
22+
`${COMMAND_NAME} notsobot`,
23+
],
24+
id: Formatter.Commands.ImageManipulationE2E.COMMAND_ID,
25+
usage: '?<emoji,user:id|mention|name,url>',
26+
},
27+
});
28+
}
29+
30+
async run(context: Command.Context, args: Formatter.Commands.ImageManipulationE2E.CommandArgs) {
31+
return Formatter.Commands.ImageManipulationE2E.createMessage(context, args);
32+
}
33+
}

src/commands/prefixed/image/e2p.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { Command, CommandClient } from 'detritus-client';
2+
3+
import { CommandCategories } from '../../../constants';
4+
import { Formatter } from '../../../utils';
5+
6+
import { BaseImageCommand } from '../basecommand';
7+
8+
9+
export const COMMAND_NAME = 'e2p';
10+
11+
export default class E2PCommand extends BaseImageCommand {
12+
constructor(client: CommandClient) {
13+
super(client, {
14+
name: COMMAND_NAME,
15+
16+
aliases: ['edges2porn'],
17+
metadata: {
18+
category: CommandCategories.IMAGE,
19+
description: 'Edges to Porn',
20+
examples: [
21+
COMMAND_NAME,
22+
`${COMMAND_NAME} notsobot`,
23+
],
24+
id: Formatter.Commands.ImageManipulationE2P.COMMAND_ID,
25+
usage: '?<emoji,user:id|mention|name,url>',
26+
},
27+
});
28+
}
29+
30+
async run(context: Command.Context, args: Formatter.Commands.ImageManipulationE2P.CommandArgs) {
31+
return Formatter.Commands.ImageManipulationE2P.createMessage(context, args);
32+
}
33+
}

src/commands/prefixed/image/explode.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,9 @@ import { Formatter } from '../../../utils';
66
import { BaseImageCommand } from '../basecommand';
77

88

9-
export interface CommandArgsBefore {
10-
scale?: number,
11-
url?: null | string,
12-
}
13-
149
export const COMMAND_NAME = 'explode';
1510

16-
export default class ExplodeCommand extends BaseImageCommand<Formatter.Commands.ImageExplode.CommandArgs> {
11+
export default class ExplodeCommand extends BaseImageCommand {
1712
constructor(client: CommandClient) {
1813
super(client, {
1914
name: COMMAND_NAME,

src/commands/prefixed/moderation/commands.disable.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Command, CommandClient, Structures } from 'detritus-client';
22
import { ChannelTypes, Permissions } from 'detritus-client/lib/constants';
3+
import { Markup } from 'detritus-client/lib/utils';
34

45
import { createGuildDisabledCommand, editGuildSettings } from '../../../api';
56
import { GuildSettings } from '../../../api/structures/guildsettings';
@@ -96,16 +97,17 @@ export default class CommandsDisable extends BaseCommand {
9697

9798
async run(context: Command.Context, args: CommandArgs) {
9899
const { command } = args;
100+
const commandId = (command.metadata && command.metadata.id) ? command.metadata.id : command.name.split(' ').join('.');
99101
const guildId = context.guildId as string;
100102

101103
const isServerWide = !args.channels && !args.roles && !args.users;
102104

103105
let settings = await GuildSettingsStore.getOrFetch(context, guildId) as GuildSettings;
104106

105-
let title = `Disabled ${command.name}`;
107+
let title = `Disabled ${Markup.codestring(commandId)}`;
106108
if (isServerWide) {
107109
title = `${title} server-wide`;
108-
await createGuildDisabledCommand(context, guildId, command.name, guildId, GuildDisableCommandsTypes.GUILD);
110+
await createGuildDisabledCommand(context, guildId, commandId, guildId, GuildDisableCommandsTypes.GUILD);
109111
settings = await GuildSettingsStore.fetch(context, guildId) as GuildSettings;
110112
} else {
111113
let channels = 0, roles = 0, users = 0;
@@ -131,7 +133,7 @@ export default class CommandsDisable extends BaseCommand {
131133
}
132134

133135
for (let payload of payloads) {
134-
const key = `${command.name}.${payload.item.id}.${payload.type}`;
136+
const key = `${commandId}.${payload.item.id}.${payload.type}`;
135137
if (!settings.disabledCommands.has(key)) {
136138
await createGuildDisabledCommand(context, guildId, command.name, payload.item.id, payload.type);
137139
}

0 commit comments

Comments
 (0)