Advertisement
Guest User

Untitled

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