Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1.  
  2. if(message.content.startsWith("/comadd")){
  3. var formated = null;
  4. if(message.channel.isPrivate) return bot.sendMessage(message, "You can't use this command on DM");
  5. var role = message.server.roles.get("name", "Bot-Commander");
  6. if(role != null || message.server.owner.id == message.author.id){
  7. if(message.author.hasRole(role) || message.server.owner.id == message.author.id) {
  8. var mes = message.content.split(" ").splice(1).join(" ");
  9. var pref = mes.split("|")[0].trim();
  10. var reply = mes.split("|")[1].trim();
  11. try{
  12. var formated = mes.split("|")[2].trmi();
  13. }catch(e){
  14. var formated = null;
  15. }
  16. if(customcom[message.server.id]){
  17. if (!customcom[message.server.id]["/" + pref]) {
  18. if(customcom[message.server.id]){
  19. customcom[message.server.id]["/" + pref] = { "reply": reply, "optionss": formated };
  20. bot.sendMessage(message, `the command /${pref} has been added to the list`)
  21. fs.writeFile("./customc.json", JSON.stringify(customcom))
  22. }else{
  23. customcom[message.server.id] = {};
  24. customcom[message.server.id]["/" + pref] = { "reply": reply, "optionss": formated };
  25. bot.sendMessage(message, `the command /${pref} has been added to the list`)
  26. fs.writeFile("./customc.json", JSON.stringify(customcom))
  27. }
  28. }else bot.sendMessage(message, "this command already exist");
  29. }
  30. }else bot.sendMessage(message, "You don't have the perm to use this command");
  31. }else bot.sendMessage(message, "You need to create the role `Bot-Commander` to get the full perm");
  32. }
  33.  
  34. if(message.content.startsWith("/comdel")){
  35. var pref = message.content.split(" ").slice(1)[0];
  36. if(message.channel.isPrivate) return bot.sendMessage(message, "You can't use this command on DM")
  37. var role = message.server.roles.get("name", "Bot-Commander");
  38. if(role != null || message.server.owner.id == message.author.id){
  39. if(message.author.hasRole(role) || message.server.owner.id == message.author.id) {
  40. if(customcom[message.server.id]){
  41. if(customcom[message.server.id]["/" + pref]){
  42. delete customcom[message.server.id]["/" + pref];
  43. bot.sendMessage(message, pref + " has been deleted");
  44. fs.writeFile("./customc.json", JSON.stringify(customcom))
  45. }else bot.sendMessage(message, 'didn\' find the command ' + pref);
  46. }else bot.sendMessage(message, "there is no custom command for this server");
  47. }
  48. }else bot.sendMessage(message, "You need to create the role `Bot-Commander` to get the full perm");
  49. }
  50.  
  51. if(message.content.startsWith("/")){
  52. if(message.channel.isPrivate) return;
  53. var pref = message.content;
  54. if(customcom[message.server.id]){
  55. if(customcom[message.server.id][pref]){
  56. if(customcom[message.server.id][pref].optionss != null){
  57. bot.sendMessage(message.author, customcom[message.server.id][pref].reply);
  58. }else{
  59. var mes = customcom[message.server.id][pref].reply.replace(/{user}/gi, message.author.mention())
  60. bot.sendMessage(message, mes)
  61. }
  62. }
  63. }else customcom[message.server.id] = {};
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement