Skip to content
This repository was archived by the owner on Jan 24, 2022. It is now read-only.

Commit 950f1ea

Browse files
committed
chore: prettify
1 parent 935129f commit 950f1ea

File tree

6 files changed

+57
-57
lines changed

6 files changed

+57
-57
lines changed

index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from "./src/Zhycorp";
1+
export * from "./src/Zhycorp";

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"./tsconfig.json"
3333
]
3434
},
35-
"extends": "@hazmi35/eslint-config/typescript"
35+
"extends": "@zhycorp/eslint-config/typescript"
3636
},
3737
"dependencies": {
3838
"@zhycorp/eslint-config": "^2.3.0",

src/Zhycorp.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
/* eslint-disable @typescript-eslint/naming-convention */
2-
import { get } from "superagent";
3-
import { getOwner } from "./api/Bot";
4-
import ZhycorpError from "./util/ZhycorpError";
5-
import type { Bot } from "./interfaces";
6-
7-
export class ZhycorpWrapper {
8-
private readonly baseURL = "https://bot.zhycorp.com";
9-
public async getBot(id: string): Promise<Bot> {
10-
const USER_PATTERN = /\d{17,19}/g;
11-
if (!USER_PATTERN.test(id)) throw Error("Invalid user id");
12-
13-
const { body: result } = await get(this.baseURL);
14-
if (!result[id]) throw new ZhycorpError("Not Found");
15-
const bot = result[id];
16-
const user = await getOwner(id);
17-
return {
18-
approved: bot.approved,
19-
botID: bot.botID,
20-
owner: {
21-
userID: bot.ownerID,
22-
userTag: user
23-
},
24-
prefix: bot.prefix,
25-
registered: bot.registered
26-
};
27-
}
28-
}
1+
/* eslint-disable @typescript-eslint/naming-convention */
2+
import { get } from "superagent";
3+
import { getOwner } from "./api/Bot";
4+
import ZhycorpError from "./util/ZhycorpError";
5+
import { Bot } from "./interfaces";
6+
7+
export class ZhycorpWrapper {
8+
private readonly baseURL = "https://bot.zhycorp.com";
9+
public async getBot(id: string): Promise<Bot> {
10+
const USER_PATTERN = /\d{17,19}/g;
11+
if (!USER_PATTERN.test(id)) throw Error("Invalid user id");
12+
13+
const { body: result } = await get(this.baseURL);
14+
if (!result[id]) throw new ZhycorpError("Not Found");
15+
const bot = result[id];
16+
const user = await getOwner(id);
17+
return {
18+
approved: bot.approved,
19+
botID: bot.botID,
20+
owner: {
21+
userID: bot.ownerID,
22+
userTag: user
23+
},
24+
prefix: bot.prefix,
25+
registered: bot.registered
26+
};
27+
}
28+
}

src/api/Bot.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { get } from "superagent";
2-
import { load } from "cheerio";
3-
4-
const botURL = "https://zhycorp.com/bot";
5-
6-
export async function getOwner(id: string): Promise<string> {
7-
const { text } = await get(`${botURL}/${id}`);
8-
const $ = load(text);
9-
10-
const result = $("p").map((i, el) => $(el).text().trim()).get();
11-
return result[0].split("\n").find((res: string) => /(.*)#\d{4}/g.exec(res));
12-
}
1+
import { get } from "superagent";
2+
import { load } from "cheerio";
3+
4+
const botURL = "https://zhycorp.com/bot";
5+
6+
export async function getOwner(id: string): Promise<string> {
7+
const { text } = await get(`${botURL}/${id}`);
8+
const $ = load(text);
9+
10+
const result = $("p").map((i, el) => $(el).text().trim()).get();
11+
return result[0].split("\n").find((res: string) => /(.*)#\d{4}/g.exec(res));
12+
}

src/interfaces/index.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
export interface Bot {
2-
botID: string;
3-
owner: {
4-
userID: string;
5-
userTag: string;
6-
};
7-
prefix: string;
8-
approved: boolean;
9-
registered: boolean;
10-
}
1+
export interface Bot {
2+
botID: string;
3+
owner: {
4+
userID: string;
5+
userTag: string;
6+
};
7+
prefix: string;
8+
approved: boolean;
9+
registered: boolean;
10+
}

src/util/ZhycorpError.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export default class ZhycorpError extends Error {
2-
public constructor(public name: string, message?: string) {
3-
super(message);
4-
}
5-
}
1+
export default class ZhycorpError extends Error {
2+
public constructor(public name: string, message?: string) {
3+
super(message);
4+
}
5+
}

0 commit comments

Comments
 (0)