@@ -51,7 +51,7 @@ export default async function (msg: Message, type: string) {
5151 . trim ( ) ;
5252
5353 const prefix = ! msg . body . startsWith ( commandPrefix ) ;
54- const senderId = msg . from . split ( "@" ) [ 0 ] ;
54+ const lid = msg . author ? msg . author . split ( "@" ) [ 0 ] : msg . from . split ( "@" ) [ 0 ] ;
5555
5656 /*
5757 * Prefix
@@ -73,21 +73,17 @@ export default async function (msg: Message, type: string) {
7373 /*
7474 * Block users from running commands.
7575 */
76- const isBlockedUser = await isBlocked (
77- msg . author ? msg . author . split ( "@" ) [ 0 ] : senderId ,
78- ) ;
79- if ( isBlockedUser ) {
80- return ;
81- }
76+ const isBlockedUser = await isBlocked ( lid ) ;
77+ if ( isBlockedUser ) return ;
8278
8379 /*
8480 * Rate limit commands to prevent abuse.
8581 */
8682 if ( ! msg . fromMe ) {
87- const rate = await rateLimiter ( msg ) ;
83+ const rate = await rateLimiter ( lid ) ;
8884 if ( rate ) return ;
8985 if ( rate === null ) {
90- msg . reply ( "Please wait a minute or so." ) ;
86+ await msg . reply ( "Please wait a minute or so." ) ;
9187 return ;
9288 }
9389
@@ -118,7 +114,7 @@ export default async function (msg: Message, type: string) {
118114 return ;
119115 }
120116
121- log . info ( "Message" , senderId , msg . body . slice ( 0 , 150 ) ) ;
117+ log . info ( "Message" , lid , msg . body . slice ( 0 , 150 ) ) ;
122118 msg . body = ! bodyHasPrefix ? msg . body : msg . body . slice ( commandPrefix . length ) ;
123119
124120 const originalReply = msg . reply . bind ( msg ) ;
@@ -129,9 +125,8 @@ export default async function (msg: Message, type: string) {
129125 ) : Promise < Message > => {
130126 let messageBody = typeof content === "string" ? Font ( content ) : content ;
131127
132- if ( Math . random ( ) < 0.5 ) {
128+ if ( Math . random ( ) < 0.5 )
133129 return await client . sendMessage ( msg . id . remote , messageBody , options ) ;
134- }
135130 return await originalReply ( messageBody , chatId , options ) ;
136131 } ;
137132
0 commit comments