Skip to content

Commit 5294ef5

Browse files
committed
feat: prevent blocked users from interacting with the bot
1 parent 9693509 commit 5294ef5

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

src/components/events/message.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,20 @@ export default async function (msg: Message, type: string) {
4141

4242
if (msg.isGif || msg.isStatus || msg.broadcast) return; // ignore them all
4343

44+
const lid = msg.author ? msg.author.split("@")[0] : msg.from.split("@")[0];
45+
4446
// process normalization
4547
msg.body = msg.body
4648
.normalize("NFKC")
4749
.replace(/[\u0300-\u036f\u00b4\u0060\u005e\u007e]/g, "")
4850
.trim();
4951

52+
/*
53+
* Block users from running commands.
54+
*/
55+
const isBlockedUser = await isBlocked(lid);
56+
if (isBlockedUser) return;
57+
5058
/*
5159
*
5260
* Check for scam urls
@@ -81,7 +89,6 @@ export default async function (msg: Message, type: string) {
8189
}
8290

8391
const prefix = !msg.body.startsWith(commandPrefix);
84-
const lid = msg.author ? msg.author.split("@")[0] : msg.from.split("@")[0];
8592

8693
/*
8794
* Prefix
@@ -163,12 +170,6 @@ export default async function (msg: Message, type: string) {
163170
return;
164171
}
165172

166-
/*
167-
* Block users from running commands.
168-
*/
169-
const isBlockedUser = await isBlocked(lid);
170-
if (isBlockedUser) return;
171-
172173
/*
173174
* Rate limit commands to prevent abuse.
174175
*/

0 commit comments

Comments
 (0)