Skip to content

Commit e796f2a

Browse files
committed
chore(code): Reformat project
1 parent 383bb62 commit e796f2a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1868
-1122
lines changed

package-lock.json

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

package.json

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
"tscompile": "tsc --build tsconfig.json",
1111
"lint": "eslint . --ignore-path .gitignore --ext .ts",
1212
"lint:fix": "eslint . --ignore-path .gitignore --ext .ts --fix",
13+
"pretty": "prettier --check src/**/*.ts",
14+
"pretty:write": "prettier --write src/**/*.ts",
1315
"start": "node --es-module-specifier-resolution=node -r dotenv/config .",
1416
"start:dev": "rimraf ./dist && npm run compile && npm start"
1517
},
@@ -28,7 +30,13 @@
2830
"npm": ">=7.0.0"
2931
},
3032
"eslintConfig": {
31-
"extends": "@clytage-pkg/eslint-config/typescript",
33+
"extends": [
34+
"@clytage-pkg/eslint-config/typescript",
35+
"prettier"
36+
],
37+
"plugins": [
38+
"prettier"
39+
],
3240
"ignorePatterns": [
3341
"dist/*",
3442
"index.js",
@@ -38,6 +46,12 @@
3846
"@typescript-eslint/no-extra-parens": "off"
3947
}
4048
},
49+
"prettier": {
50+
"tabWidth": 4,
51+
"trailingComma": "none",
52+
"arrowParens": "avoid",
53+
"printWidth": 120
54+
},
4155
"dependencies": {
4256
"@discordjs/voice": "0.9.0",
4357
"@swc/cli": "0.1.57",
@@ -61,6 +75,9 @@
6175
"@typescript-eslint/eslint-plugin": "5.26.0",
6276
"@typescript-eslint/parser": "5.26.0",
6377
"eslint": "8.16.0",
78+
"eslint-config-prettier": "^8.5.0",
79+
"eslint-plugin-prettier": "^4.0.0",
80+
"prettier": "^2.6.2",
6481
"rimraf": "^3.0.2",
6582
"typescript": "4.7.2"
6683
},

src/bot.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ const client = new Rawon(clientOptions);
66

77
process
88
.on("exit", code => client.logger.info(`NodeJS process exited with code ${code}`))
9-
.on("unhandledRejection", reason => client.logger.error("UNHANDLED_REJECTION:", (reason as Error).stack ? reason : new NoStackError(reason as string)))
9+
.on("unhandledRejection", reason =>
10+
client.logger.error(
11+
"UNHANDLED_REJECTION:",
12+
(reason as Error).stack ? reason : new NoStackError(reason as string)
13+
)
14+
)
1015
.on("warning", (...args) => client.logger.warn(...args))
1116
.on("uncaughtException", err => {
1217
client.logger.error("UNCAUGHT_EXCEPTION:", err);
1318
client.logger.warn("Uncaught Exception detected, trying to restart...");
1419
process.exit(1);
1520
});
1621

17-
client.build()
18-
.catch(e => client.logger.error("PROMISE_ERR:", e));
22+
client.build().catch(e => client.logger.error("PROMISE_ERR:", e));

src/commands/developers/EvalCommand.ts

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,10 @@ export class EvalCommand extends BaseCommand {
2020
const msg = ctx;
2121
const client = this.client;
2222

23-
const code = ctx.args.join(" ")
24-
.replace(
25-
/^\s*\n?(```(?:[^\s]+\n)?(.*?)```|.*)$/s,
26-
(_, a: string, b) => a.startsWith("```") ? b : a
27-
);
28-
const embed = createEmbed("info")
29-
.addField("Input", `\`\`\`js\n${code}\`\`\``);
23+
const code = ctx.args
24+
.join(" ")
25+
.replace(/^\s*\n?(```(?:[^\s]+\n)?(.*?)```|.*)$/s, (_, a: string, b) => (a.startsWith("```") ? b : a));
26+
const embed = createEmbed("info").addField("Input", `\`\`\`js\n${code}\`\`\``);
3027

3128
try {
3229
if (!code) {
@@ -35,25 +32,18 @@ export class EvalCommand extends BaseCommand {
3532
});
3633
}
3734

38-
const isAsync = (/.* --async( +)?(--silent)?$/).test(code);
39-
const isSilent = (/.* --silent( +)?(--async)?$/).test(code);
40-
const toExecute = isAsync || isSilent
41-
? code.replace(/--(async|silent)( +)?(--(silent|async))?$/, "")
42-
: code;
43-
const evaled = inspect(
44-
await eval(
45-
isAsync
46-
? `(async () => {\n${toExecute}\n})()`
47-
: toExecute
48-
), { depth: 0 }
49-
);
35+
const isAsync = /.* --async( +)?(--silent)?$/.test(code);
36+
const isSilent = /.* --silent( +)?(--async)?$/.test(code);
37+
const toExecute =
38+
isAsync || isSilent ? code.replace(/--(async|silent)( +)?(--(silent|async))?$/, "") : code;
39+
const evaled = inspect(await eval(isAsync ? `(async () => {\n${toExecute}\n})()` : toExecute), {
40+
depth: 0
41+
});
5042

5143
if (isSilent) return;
5244

5345
const cleaned = this.clean(evaled);
54-
const output = cleaned.length > 1024
55-
? `${await this.hastebin(cleaned)}.js`
56-
: `\`\`\`js\n${cleaned}\`\`\``;
46+
const output = cleaned.length > 1024 ? `${await this.hastebin(cleaned)}.js` : `\`\`\`js\n${cleaned}\`\`\``;
5747

5848
embed.addField(i18n.__("commands.developers.eval.outputString"), output);
5949
ctx.send({
@@ -65,9 +55,7 @@ export class EvalCommand extends BaseCommand {
6555
} catch (e) {
6656
const cleaned = this.clean(String(e));
6757
const isTooLong = cleaned.length > 1024;
68-
const error = isTooLong
69-
? `${await this.hastebin(cleaned)}.js`
70-
: `\`\`\`js\n${cleaned}\`\`\``;
58+
const error = isTooLong ? `${await this.hastebin(cleaned)}.js` : `\`\`\`js\n${cleaned}\`\`\``;
7159

7260
embed.setColor("RED").addField(i18n.__("commands.developers.eval.errorString"), error);
7361
ctx.send({
@@ -88,9 +76,11 @@ export class EvalCommand extends BaseCommand {
8876
}
8977

9078
private async hastebin(text: string): Promise<string> {
91-
const result = await this.client.request.post("https://bin.clytage.org/documents", {
92-
body: text
93-
}).json<{ key: string }>();
79+
const result = await this.client.request
80+
.post("https://bin.clytage.org/documents", {
81+
body: text
82+
})
83+
.json<{ key: string }>();
9484

9585
return `https://bin.clytage.org/${result.key}`;
9686
}

src/commands/general/AboutCommand.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@ export class AboutCommand extends BaseCommand {
3636
];
3737
const value = createTable(values);
3838

39-
void ctx.reply({
40-
embeds: [createEmbed("info", `\`\`\`asciidoc\n${value}\n\`\`\``)
41-
.setAuthor({
42-
name: i18n.__mf("commands.general.about.aboutFooter", {
43-
botname: this.client.user?.username ?? "Unknown"
39+
void ctx
40+
.reply({
41+
embeds: [
42+
createEmbed("info", `\`\`\`asciidoc\n${value}\n\`\`\``).setAuthor({
43+
name: i18n.__mf("commands.general.about.aboutFooter", {
44+
botname: this.client.user?.username ?? "Unknown"
45+
})
4446
})
45-
})]
46-
}).catch(e => this.client.logger.error("ABOUT_CMD_ERR:", e));
47+
]
48+
})
49+
.catch(e => this.client.logger.error("ABOUT_CMD_ERR:", e));
4750
}
4851
}

0 commit comments

Comments
 (0)