Advertisement
AEAEAEAEarray

add admin commands

Aug 29th, 2021
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const send = MPP.chat.send; //i used it extra
  2. const prefix = "."; //just exmaple
  3.  
  4. //method 1 - only you can use
  5. MPP.client.on('a', function(msg){ //for take your id and user id (who will use command)
  6.     var you = MPP.client.getOwnParticipant(); //its you
  7.     var userid = msg.p.id; //its userid who will use command
  8.     var yourid = you.id; //its your id
  9.     //and here its done
  10.     //now follow methods
  11.  
  12.     //exmaple of a command here bellow
  13.     if (msg.a.startsWith(prefix+"command")){
  14.         if (userid != yourid) return send("You don't have any permission to use this command"); // "!=" it means if not not equals and "==" it means if equals
  15.         //now your main command code bellow...............
  16.     }
  17. })
  18.  
  19. //method 2 - adding custom admins
  20. const admins = ["368bff184db7a3c669da1ca5", "a8c86bb6e74c9ec8900e061a"]; //add your curstom admin id here to make someone admin
  21.  
  22. //its the important admin code to get admin id
  23.  
  24. var admin = admins.length;
  25. if (admin > 0){
  26.     var i;
  27.     for(i = 0; i < admins.length; ++i)
  28.     var adminuser = admins[i];
  29. }
  30.  
  31. //now addning command
  32. MPP.client.on('a', function msg(){
  33.     var userid = msg.p._id;
  34.     if (msg.a.startsWith(prefix+"command")){
  35.         if (userid != adminuser) return send("You dont have any permission to use this command");
  36.         //your command code bellow....................
  37.     }
  38. })
  39.  
  40. //method 3 - adding cudtom id
  41. MPP.client.on('a', function msg(){
  42.     var userid = msg.p._id;
  43.     if (msg.a.startsWith(prefix+"command")){
  44.         if (userid != "368bff184db7a3c669da1ca5") return send("You don't have any permission to use this command");
  45.         //your command code bellow
  46.         //its "368bff184db7a3c669da1ca5" means its admin
  47.     }
  48. })
  49.  
  50. //and thx for checking it :)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement