Skip to content

Commit bc67cdf

Browse files
committed
feat: prettify commands message and added event to make debugging message way easier and simplier
1 parent a2f026f commit bc67cdf

26 files changed

Lines changed: 234 additions & 158 deletions

src/commands/dcma.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export default async function (msg: Message) {
1414
if (!/^dcma$/i.test(msg.body)) return;
1515

1616
const text = `
17-
\`DCMA\`
17+
\`DCMA\`
18+
1819
This bot is intended for educational and entertainment purposes only.
1920
The owner of this bot does not claim ownership of any content shared through it.
2021
If you believe that your content has been used without permission,

src/commands/docker.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ export default async function (msg: Message) {
5353
}
5454
const repo = response.data;
5555
const info = `
56-
\`${repo.name}\`
57-
${repo.description || ""}
56+
\`${repo.name}\`
57+
${repo.description || ""}
5858
59-
Stars: ${repo.star_count}
60-
Pulls: ${repo.pull_count}
61-
Last Updated: ${new Date(repo.last_updated).toLocaleDateString()}
62-
Link: https://hub.docker.com/r/${repo.namespace}/${repo.name}
63-
`;
59+
Stars: ${repo.star_count}
60+
Pulls: ${repo.pull_count}
61+
Last Updated: ${new Date(repo.last_updated).toLocaleDateString()}
62+
Link: https://hub.docker.com/r/${repo.namespace}/${repo.name}
63+
`;
6464
await msg.reply(info);
6565
}

src/commands/event.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { Message } from "../../types/message";
2+
3+
export const info = {
4+
command: "event",
5+
description: "Return the event of the message or the quoted message.",
6+
usage: "event",
7+
example: "event",
8+
role: "user",
9+
cooldown: 5000,
10+
};
11+
12+
export default async function (msg: Message) {
13+
if (!/^event/i.test(msg.body)) return;
14+
15+
let event: Message;
16+
17+
if (msg.hasQuotedMsg) {
18+
const quotedEvent = await msg.getQuotedMessage();
19+
event = quotedEvent;
20+
} else {
21+
event = msg;
22+
}
23+
24+
await msg.reply("```" + JSON.stringify(event, null, 2) + "```");
25+
}

src/commands/fork.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,16 @@ export default async function (msg: Message) {
1313
if (!/^fork$/i.test(msg.body)) return;
1414

1515
const text = `
16-
\`Canis for WhatsApp\`
16+
\`Canis for WhatsApp\`
1717
https://github.com/mrepol742/project-canis
1818
19-
\`Canis for Telegram\`
19+
\`Canis for Telegram\`
2020
https://github.com/mrepol742/project-canis-ts
2121
2222
This bot is not affiliated, endorsed, partner, or connected to Meta.
2323
Use it at your own RISK.
2424
2525
Type \`Legal\` for more information.
26-
`;
27-
26+
`;
2827
await msg.reply(text);
2928
}

src/commands/github.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Message } from "../../types/message"
1+
import { Message } from "../../types/message";
22
import axios from "../components/axios";
33
import log from "../components/utils/log";
44
import fs from "fs/promises";
@@ -29,21 +29,20 @@ export default async function (msg: Message) {
2929

3030
const user = response.data;
3131
const info = `
32-
\`${user.name || user.login}\
33-
${user.bio || ""}
32+
\`${user.name || user.login}\
33+
${user.bio || ""}
3434
35-
Place: ${user.location || "N/A"}
36-
Followers: ${user.followers}
37-
Following: ${user.following}
38-
Gists: ${user.public_gists}
39-
Repo: ${user.public_repos}
40-
X: ${
41-
user.twitter_username
42-
? `https://twitter.com/${user.twitter_username}`
43-
: "N/A"
44-
}
45-
Link: ${user.blog || "N/A"}
35+
Place: ${user.location || "N/A"}
36+
Followers: ${user.followers}
37+
Following: ${user.following}
38+
Gists: ${user.public_gists}
39+
Repo: ${user.public_repos}
40+
X: ${
41+
user.twitter_username
42+
? `https://twitter.com/${user.twitter_username}`
43+
: "N/A"
44+
}
45+
Link: ${user.blog || "N/A"}
4646
`;
47-
4847
await msg.reply(info);
4948
}

src/commands/help.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,27 @@ function buildUserPage(
2929
totalPages: number,
3030
): string {
3131
let response = `
32-
Use \`help [page] | [role] | [command]\` for more details on a specific command.\n
33-
< ─────────── >\n • ${userCommands.join("\n • ") || "_None_"}\n\n`;
34-
response += `< ─────────── >`;
35-
response += `\n\`Page ${page} of ${totalPages}\``;
32+
\`help [page] | [role] | [command]\` for more details on a specific command.
33+
34+
| ─────────── >
35+
| • ${userCommands.join("\n | • ") || "_None_"}
36+
| ─────────── >
37+
38+
\`Page ${page} of ${totalPages}\`
39+
`;
3640
return response;
3741
}
3842

3943
function buildAdminPage(adminCommands: string[]): string {
40-
return `
41-
Use \`help [page] | [role] | [command]\` for more details on a specific command.\n
42-
< ─────────── >\n • ${
43-
adminCommands.join("\n • ") || "_None_"
44-
}\n< ─────────── >
44+
let response = `
45+
\`help [page] | [role] | [command]\` for more details on a specific command.
46+
47+
| ─────────── >
48+
| • ${adminCommands.join("\n | • ") || "_None_"}
49+
| ─────────── >
50+
4551
`;
52+
return response;
4653
}
4754

4855
export default async function (msg: Message) {

src/commands/huggingface.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ export default async function (msg: Message) {
2828
}
2929
const models = response.data[0];
3030
const info = `
31-
\`${models.modelId}\`
32-
${models.tags.splice(0, 5).join(", ") || "N/A"}
31+
\`${models.modelId}\`
32+
${models.tags.splice(0, 5).join(", ") || "N/A"}
3333
34-
Library: ${models.library_name}
35-
Pipeline: ${models.pipeline_tag}
36-
Likes: ${models.likes}
37-
Downloads: ${models.downloads}
38-
Created At: ${new Date(models.createdAt).toLocaleString()}
39-
Private: ${models.private ? "Yes" : "No"}
40-
Model URL: https://huggingface.co/${models.modelId}
41-
`;
34+
Library: ${models.library_name}
35+
Pipeline: ${models.pipeline_tag}
36+
Likes: ${models.likes}
37+
Downloads: ${models.downloads}
38+
Created At: ${new Date(models.createdAt).toLocaleString()}
39+
Private: ${models.private ? "Yes" : "No"}
40+
Model URL: https://huggingface.co/${models.modelId}
41+
`;
4242
await msg.reply(info);
4343
}

src/commands/legal.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Message } from "../../types/message"
1+
import { Message } from "../../types/message";
22
import log from "../components/utils/log";
33

44
export const info = {
@@ -11,26 +11,26 @@ export const info = {
1111
};
1212

1313
export default async function (msg: Message) {
14-
if (!/^legal$/i.test(msg.body)) return;
14+
if (!/^legal$/i.test(msg.body)) return;
1515

16-
const text = `
16+
const text = `
1717
\`Legal Commands\`
1818
19-
\`terms\`
20-
Display the terms of service of the bot.
19+
\`terms\`
20+
Display the terms of service of the bot.
2121
22-
\`privacy\`
23-
Display the privacy policy of the bot.
22+
\`privacy\`
23+
Display the privacy policy of the bot.
2424
25-
\`dcma\`
26-
Display the DCMA policy of the bot.
25+
\`dcma\`
26+
Display the DCMA policy of the bot.
2727
28-
\`license\`
29-
Display the License of the bot.
28+
\`license\`
29+
Display the License of the bot.
3030
31-
\`contact\`
32-
mrepol742@gmail.com
31+
\`contact\`
32+
mrepol742@gmail.com
3333
`;
3434

35-
await msg.reply(text);
35+
await msg.reply(text);
3636
}

src/commands/license.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default async function (msg: Message) {
1414
if (!/^license/i.test(msg.body)) return;
1515

1616
const text = `
17-
\`License\`
17+
\`License\`
1818
MIT License with Commons Clause and Commercial Licensing
1919
2020
Copyright (c) 2025 Melvin Jones Repol

src/commands/npm.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ export default async function (msg: Message) {
7070
Homepage: ${homepage}
7171
Repository: ${repository}
7272
Last Published: ${formattedPublished}
73-
`;
74-
73+
`;
7574
await msg.reply(repo);
7675
}

0 commit comments

Comments
 (0)