File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { Message } from "../../types/message"
1+ import { Message } from "../../types/message" ;
22import log from "../components/utils/log" ;
33import { exec } from "child_process" ;
44import util from "util" ;
55import { prisma } from "../components/prisma" ;
66
77export const info = {
88 command : "block" ,
9- description : "Block or unblock users from sending messages ." ,
10- usage : "block <@user> [--rem] " ,
9+ description : "Block users from the bot ." ,
10+ usage : "block <@user>" ,
1111 example : "block @user123" ,
1212 role : "admin" ,
1313 cooldown : 5000 ,
@@ -19,18 +19,7 @@ export default async function (msg: Message) {
1919 return ;
2020 }
2121
22- if ( / ^ b l o c k \s - - r e m / . test ( msg . body ) ) {
23- for ( const userId of msg . mentionedIds ) {
24- const lid = userId . split ( "@" ) [ 0 ] ;
25-
26- await prisma . block . delete ( {
27- where : { lid } ,
28- } ) ;
29- }
30-
31- await msg . react ( "❌" ) ;
32- return ;
33- }
22+ await msg . react ( "🔄" ) ;
3423
3524 for ( const userId of msg . mentionedIds ) {
3625 const lid = userId . split ( "@" ) [ 0 ] ;
Original file line number Diff line number Diff line change 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+ import { getKey } from "../components/utils/rateLimiter" ;
7+ import redis from "../components/redis" ;
8+
9+ export const info = {
10+ command : "unblock" ,
11+ description : "Unblock the users from the bot & rate limiter." ,
12+ usage : "unblock <@user>" ,
13+ example : "unblock @user123" ,
14+ role : "admin" ,
15+ cooldown : 5000 ,
16+ } ;
17+
18+ export default async function ( msg : Message ) {
19+ if ( msg . mentionedIds . length === 0 ) {
20+ await msg . reply ( "Please mention a user to unblock." ) ;
21+ return ;
22+ }
23+
24+ await msg . react ( "🔄" ) ;
25+
26+ for ( const userId of msg . mentionedIds ) {
27+ const lid = userId . split ( "@" ) [ 0 ] ;
28+
29+ await prisma . block . delete ( {
30+ where : { lid } ,
31+ } ) ;
32+
33+ const key = getKey ( userId ) ;
34+ const entryRaw = await redis . get ( key ) ;
35+
36+ await redis . set (
37+ key ,
38+ JSON . stringify ( {
39+ timestamps : [ ] as number [ ] ,
40+ penaltyCount : 0 ,
41+ penaltyUntil : 0 ,
42+ } ) ,
43+ ) ;
44+ }
45+
46+ await msg . react ( "✅" ) ;
47+ }
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ const LIMIT = 5;
77const BASE_WINDOW_MS = 30 * 1000 ;
88const PENALTY_INCREMENT_MS = 10 * 1000 ;
99
10- function getKey ( number : string ) {
10+ export function getKey ( number : string ) {
1111 return `rate:${ number } ` ;
1212}
1313
You can’t perform that action at this time.
0 commit comments