Skip to content

Commit 75f3c65

Browse files
committed
feat: add commandCount to User model and update related commands
- Added commandCount field to User model in Prisma schema. - Updated findOrCreateUser function to increment commandCount on user command execution. - Enhanced command files to include info object with command details (description, usage, example, role, cooldown). - Implemented help command to list all available commands with pagination. - Removed unused commands (ls, shell) to clean up the codebase. - Updated message and reaction event handlers to improve user experience.
1 parent f758b08 commit 75f3c65

41 files changed

Lines changed: 434 additions & 120 deletions

Some content is hidden

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

package-lock.json

Lines changed: 2 additions & 2 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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "project-canis",
3-
"version": "10.0.2",
3+
"version": "11.0.0",
44
"description": "Canis Major and the constellation Canis Minor, the “lesser dog,” are widely regarded as two hunting hounds that follow Orion, the great hunter of ancient Greek legends.",
55
"private": true,
66
"main": "src/index.ts",
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- AlterTable
2+
ALTER TABLE `User` ADD COLUMN `commandCount` INTEGER NOT NULL DEFAULT 0;

prisma/schema.prisma

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ datasource db {
1515
}
1616

1717
model User {
18-
id Int @id @default(autoincrement())
19-
lid String @unique
20-
name String
21-
number String
22-
countryCode String
23-
type String
24-
mode String
25-
about String?
26-
createdAt DateTime @default(now())
27-
updatedAt DateTime @updatedAt
18+
id Int @id @default(autoincrement())
19+
lid String @unique
20+
name String
21+
number String
22+
countryCode String
23+
type String
24+
mode String
25+
about String?
26+
commandCount Int @default(0)
27+
createdAt DateTime @default(now())
28+
updatedAt DateTime @updatedAt
2829
}
2930

3031
model Block {

src/commands/ai.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ import { client } from "../components/client";
1010
export const command = "ai";
1111
export const role = "user";
1212

13+
export const info = {
14+
command: "ai",
15+
description: "Interact with the AI agent.",
16+
usage: "ai <query>",
17+
example: "ai What is the weather like today?",
18+
role: "user",
19+
cooldown: 5000,
20+
};
21+
1322
export default async function (msg: Message) {
1423
const query = msg.body.replace(/^ai\b\s*/i, "").trim();
1524
if (query.length === 0) {

src/commands/alert.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@ import axios from "axios";
33
import log from "../components/utils/log";
44
import fs from "fs/promises";
55

6-
export const command = "alert";
7-
export const role = "user";
6+
export const info = {
7+
command: "alert",
8+
description: "Generate an alert image with the provided text.",
9+
usage: "alert <text>",
10+
example: "alert This is an important message!",
11+
role: "user",
12+
cooldown: 5000,
13+
};
814

915
export default async function (msg: Message) {
1016
const query = msg.body.replace(/^alert\b\s*/i, "").trim();

src/commands/bible.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@ import { Message } from "whatsapp-web.js";
22
import axios from "axios";
33
import log from "../components/utils/log";
44

5-
export const command = "bible";
6-
export const role = "user";
5+
export const info = {
6+
command: "bible",
7+
description: "Fetch a Bible verse or the verse of the day.",
8+
usage: "bible --random | --today | --verse <book chapter:verse>",
9+
example: "bible --verse Job 4:9",
10+
role: "user",
11+
cooldown: 5000,
12+
};
713

814
export default async function (msg: Message) {
915
const query = msg.body.replace(/^bible\b\s*/i, "").trim();

src/commands/block.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@ import { exec } from "child_process";
44
import util from "util";
55
import { prisma } from "../components/prisma";
66

7-
export const command = "block";
8-
export const role = "admin";
9-
10-
export default async function block(msg: Message) {
7+
export const info = {
8+
command: "block",
9+
description: "Block or unblock users from sending messages.",
10+
usage: "block <@user> [--rem]",
11+
example: "block @user123",
12+
role: "admin",
13+
cooldown: 5000,
14+
};
15+
16+
export default async function (msg: Message) {
1117
if (msg.mentionedIds.length === 0) {
1218
await msg.reply("Please mention a user to block.");
1319
return;

src/commands/caution.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ import log from "../components/utils/log";
44
import fs from "fs/promises";
55
import { client } from "../components/client";
66

7-
export const command = "caution";
8-
export const role = "user";
7+
export const info = {
8+
command: "caution",
9+
description: "Generate a caution image with the provided text.",
10+
usage: "caution <text>",
11+
example: "caution This is a caution message!",
12+
role: "user",
13+
cooldown: 5000,
14+
};
915

1016
export default async function (msg: Message) {
1117
const query = msg.body.replace(/^caution\b\s*/i, "").trim();

src/commands/github.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ import log from "../components/utils/log";
44
import fs from "fs/promises";
55
import { client } from "../components/client";
66

7-
export const command = "github";
8-
export const role = "user";
7+
export const info = {
8+
command: "github",
9+
description: "Fetch GitHub user information.",
10+
usage: "github <username>",
11+
example: "github octocat",
12+
role: "user",
13+
cooldown: 5000,
14+
};
915

1016
export default async function (msg: Message) {
1117
const query = msg.body.replace(/^github\b\s*/i, "").trim();

0 commit comments

Comments
 (0)