@@ -2,41 +2,39 @@ import { client } from '../../services/whatsapp';
22import { company } from '../../config/integrantes.json' ;
33import type { Message , GroupChat } from 'whatsapp-web.js' ;
44
5- export default class QuoteCommand {
6- async execute ( msg : Message ) {
7- const chat : GroupChat = ( await msg . getChat ( ) ) as any ;
8- const user = await msg . getContact ( ) ;
9-
10- const { user : contato } = user . id ;
5+ export const QuoteCommand = {
6+ async execute ( msg : Message ) : Promise < Message > {
7+ const chat : Partial < GroupChat > = await msg . getChat ( ) ;
8+ const {
9+ id : { user : contato } ,
10+ } = await msg . getContact ( ) ;
1111
1212 await chat . sendStateTyping ( ) ;
1313
1414 if ( ! chat . isGroup ) {
1515 return msg . reply ( 'Comando apenas para grupos!' ) ;
1616 }
1717
18- company . map ( async ( { numero, admin } ) => {
19- if ( numero == contato ) {
20- if ( ! admin ) {
21- return msg . reply (
22- 'Ops, você não tem permissão para executar este comando!' ,
23- ) ;
24- }
18+ company . forEach ( async ( { numero, admin } ) : Promise < Message > => {
19+ if ( numero !== contato ) return ;
2520
26- let text = '' ;
27- const mentions = [ ] ;
21+ if ( ! admin ) {
22+ return msg . reply (
23+ 'Ops, você não tem permissão para executar este comando!' ,
24+ ) ;
25+ }
2826
29- for ( const participant of chat . participants ) {
30- const contact = await client . getContactById (
31- participant . id . _serialized ,
32- ) ;
27+ let text = '' ;
28+ const mentions = [ ] ;
3329
34- mentions . push ( contact ) ;
35- text += `@${ participant . id . user } ` ;
36- }
30+ for ( const participant of chat . participants ) {
31+ const contact = await client . getContactById ( participant . id . _serialized ) ;
3732
38- return chat . sendMessage ( text , { mentions } ) ;
33+ mentions . push ( contact ) ;
34+ text += `@${ participant . id . user } ` ;
3935 }
36+
37+ return chat . sendMessage ( text , { mentions } ) ;
4038 } ) ;
41- }
42- }
39+ } ,
40+ } ;
0 commit comments