Skip to content

Commit eaffa14

Browse files
committed
feat: add kick command for admin/groupadmin
1 parent f58153a commit eaffa14

3 files changed

Lines changed: 42 additions & 3 deletions

File tree

src/commands/kick.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { Message } from "../../types/message";
2+
import log from "../components/utils/log";
3+
import { exec } from "child_process";
4+
import util from "util";
5+
import { prisma } from "../components/prisma";
6+
7+
export const info = {
8+
command: "kick",
9+
description: "Kick users from the group.",
10+
usage: "kick <@user>",
11+
example: "kick @user123",
12+
role: "admin",
13+
cooldown: 5000,
14+
};
15+
16+
export default async function (msg: Message) {
17+
if (msg.mentionedIds.length === 0) {
18+
await msg.reply("Please mention a user to block.");
19+
return;
20+
}
21+
22+
const chat = await msg.getChat();
23+
24+
if (!chat.isGroup) {
25+
await msg.reply("This command only works in groups.");
26+
return;
27+
}
28+
const groupChat = chat as any;
29+
30+
try {
31+
for (const userId of msg.mentionedIds) {
32+
await groupChat.removeParticipants([userId]);
33+
}
34+
35+
} catch (err) {
36+
log.error("Kick", err);
37+
await msg.reply("Failed to kick user. Make sure I am an admin.");
38+
}
39+
}

src/commands/top.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ export default async function (msg: Message) {
2121
}
2222

2323
const text = `
24-
\`Top Users:\`
24+
\`Top Users by Activity:\`
2525
2626
${user
2727
.filter((u, index) => u.commandCount !== 0 && index < 20)
2828
.map((u, index) => {
2929
const displayName =
3030
u.name.length > 12 ? u.name.slice(0, 12) + "..." : u.name;
31-
return `${index + 1}. ${displayName} - ${u.commandCount + u.quizAnswered} Points`;
31+
return `${index + 1}. ${displayName}: ${u.commandCount + u.quizAnswered} Points`;
3232
})
3333
.join("\n ")}
3434
`;

src/commands/update.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default async function (msg: Message) {
2424
if (stdout) log.info("Update", `git pull stdout:\n${stdout}`);
2525
if (stderr) log.warn("Update", `git pull stderr:\n${stderr}`);
2626

27-
await msg.reply("Repository updated successfully!");
27+
await msg.reply(stdout || stderr);
2828
} catch (error: any) {
2929
log.error("Update", `git pull failed: ${error.message}`);
3030
await msg.reply("Failed to update repository. Check logs.");

0 commit comments

Comments
 (0)