Skip to content

Commit 0d7ed7d

Browse files
committed
feat: added noodle code checker
1 parent b016236 commit 0d7ed7d

3 files changed

Lines changed: 44 additions & 0 deletions

File tree

package-lock.json

Lines changed: 7 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"genius-lyrics": "^4.4.7",
3838
"google-tts-api": "^2.0.2",
3939
"groq-sdk": "^0.27.0",
40+
"is-spaghetti-code": "^1.0.1",
4041
"npmlog": "^7.0.1",
4142
"ollama": "^0.5.16",
4243
"openai": "^5.10.2",

src/commands/noodles.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { Message } from "../../types/message";
2+
import spagehettiCode from "is-spaghetti-code";
3+
4+
export const info = {
5+
command: "noodles",
6+
description:
7+
"Check if the code was written well or shit has taken place elsewhere.",
8+
usage: "noodles",
9+
example: "noodles",
10+
role: "user",
11+
cooldown: 5000,
12+
};
13+
14+
export default async function (msg: Message) {
15+
if (!/^noodles/i.test(msg.body)) return;
16+
17+
if (!msg.hasQuotedMsg) {
18+
await msg.reply("This only works on qouted messages.");
19+
return;
20+
}
21+
22+
const qouted = await msg.getQuotedMessage();
23+
qouted.body = qouted.body
24+
.normalize("NFKC")
25+
.replace(/[\u0300-\u036f\u00b4\u0060\u005e\u007e]/g, "")
26+
.trim();
27+
const result = spagehettiCode(qouted.body);
28+
const text = `
29+
\`Results\`
30+
31+
Spaghetti Code: ${result.isSpaghetti}
32+
Max Nesting Level: ${result.maxNestingLevel}
33+
Long Function Count: ${result.longFunctionCount}
34+
`;
35+
await msg.reply(text);
36+
}

0 commit comments

Comments
 (0)