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" ;
2+ import log from "../components/utils/log" ;
3+
4+ export const info = {
5+ command : "demote" ,
6+ description : "Demote mentioned users from admin." ,
7+ usage : "demote <@user>" ,
8+ example : "demote @user123" ,
9+ role : "admin" ,
10+ cooldown : 5000 ,
11+ } ;
12+
13+ export default async function ( msg : Message ) {
14+ if ( msg . mentionedIds . length === 0 ) {
15+ await msg . reply ( "Please mention a user to demote." ) ;
16+ return ;
17+ }
18+
19+ const chat = await msg . getChat ( ) ;
20+
21+ if ( ! chat . isGroup ) {
22+ await msg . reply ( "This command only works in groups." ) ;
23+ return ;
24+ }
25+
26+ const groupChat = chat as any ;
27+
28+ try {
29+ for ( const userId of msg . mentionedIds ) {
30+ await groupChat . demoteParticipants ( [ userId ] ) ;
31+ }
32+ } catch ( err ) {
33+ log . error ( "Demote" , err ) ;
34+ await msg . reply ( "Failed to demote user. Make sure I am an admin." ) ;
35+ }
36+ }
Original file line number Diff line number Diff line change 1+ import { Message } from "../../types/message" ;
2+ import log from "../components/utils/log" ;
3+
4+ export const info = {
5+ command : "promote" ,
6+ description : "Promote mentioned users to admin." ,
7+ usage : "promote <@user>" ,
8+ example : "promote @user123" ,
9+ role : "admin" ,
10+ cooldown : 5000 ,
11+ } ;
12+
13+ export default async function ( msg : Message ) {
14+ if ( msg . mentionedIds . length === 0 ) {
15+ await msg . reply ( "Please mention a user to promote." ) ;
16+ return ;
17+ }
18+
19+ const chat = await msg . getChat ( ) ;
20+
21+ if ( ! chat . isGroup ) {
22+ await msg . reply ( "This command only works in groups." ) ;
23+ return ;
24+ }
25+
26+ const groupChat = chat as any ;
27+
28+ try {
29+ for ( const userId of msg . mentionedIds ) {
30+ await groupChat . promoteParticipants ( [ userId ] ) ;
31+ }
32+ } catch ( err ) {
33+ log . error ( "Promote" , err ) ;
34+ await msg . reply ( "Failed to promote user. Make sure I am an admin." ) ;
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments