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 "whatsapp-web.js" ;
2+ import log from "npmlog" ;
3+ import { commands } from "../index" ;
4+
5+ export const command = "cmd" ;
6+ export const role = "user" ;
7+
8+ export default async function ( msg : Message ) {
9+ try {
10+ const userCommands = Object . values ( commands )
11+ . filter ( ( cmd : any ) => cmd . role === "user" )
12+ . map ( ( cmd : any ) => cmd . command )
13+ . join ( ", " ) ;
14+
15+ const adminCommands = Object . values ( commands )
16+ . filter ( ( cmd : any ) => cmd . role === "admin" )
17+ . map ( ( cmd : any ) => cmd . command )
18+ . join ( ", " ) ;
19+
20+ let response = "*User:*\n" + userCommands ;
21+ if ( adminCommands ) {
22+ response += "\n\n*Admin:*\n" + adminCommands ;
23+ }
24+
25+ await msg . reply ( response ) ;
26+ } catch ( error ) {
27+ log . error ( "Command" , "Error displaying commands:" , error ) ;
28+ await msg . reply ( "Failed to display commands." ) ;
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments