Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.43 KB | None | 0 0
  1. let banMember = message.mentions.members.first() || message.guild.members.get(args[0]);
  2. if(!banMember) return message.channel.send("Please provide a member to ban!");
  3.  
  4. let userone = message.guild.member(message.mentions.users.first());
  5. let idMember = `DISCRIMINATORY ID: #${message.mentions.users.first().discriminator}`;
  6. var issuer = message.author;
  7.  
  8. if(!message.member.hasPermission(["BAN_MEMBERS", "ADMINISTRATOR"])) return message.channel.send("You don't have enough permissions to perform this command!").then(sent => console.log(`${issuer.username} tried to use "!tempban" command on Object ID: ${userone} ${idMember}, ACCESS: DENIED, REASON: He/She doesn't have Administrator permissions or ban permissions!`)).catch(console.error);
  9.  
  10. //converts in min/hrs and days text
  11. let convertor;
  12.  
  13.  
  14.  
  15. let bantime = args[1];
  16. if (!bantime) return message.reply("tell me how much time you want the member mentioned to be banned!");
  17. //converts from secoonds to min, otherwise if it's lower than 1 min, it will show seconds
  18. if(bantime >= 61 && bantime <= 3599){
  19. convertor = "minutes"
  20. }else{
  21. convertor = "seconds"
  22. };
  23. //converts from seconds to hours, otherwise if it's lower than 1 hour it will display minutes
  24. if(bantime >= 3601 && bantime <= 86399){
  25. convertor = "hours"
  26. };
  27. //converts from seconds to days otherwise if it's lower than 1 day it will show hours
  28. if(bantime > 86401){
  29. convertor = "days"
  30. };
  31. //converts from seconds to weeks otherwise if it's lower than 1 week it will show days
  32. if(bantime > 604801){
  33. convertor = "weeks"
  34. }
  35. //this is just a joke :)
  36. if(bantime > 31536001){
  37. convertor = "years";
  38. }
  39. //end of converting
  40.  
  41. //converts the numbers from seconds to min, hours and days and weeks because why not
  42. var minutes = (bantime / 60);
  43. var hours = (bantime/3600);
  44. var days = (bantime/86400);
  45. var weeks = (bantime/604800);
  46. var years = (bantime/31536000);
  47. //now time to choose carefully what to take and what to not
  48. //this checks if it's over 60 seconds and lower or equal with 3600 seconds, it will choose minutes var.
  49. let realtime;
  50. if(bantime > 60 && bantime <= 3600){
  51. realtime = minutes;
  52. };
  53. //this checks if it's over 3601 seconds(1 hour and 1 second) and lower or equal with 86400 s(1 day), it will choose hours.
  54. if(bantime >=3601 && bantime <= 86400){
  55. realtime = hours;
  56. };
  57. //this checks if it's over 86401 seconds(1 day and 1 second) it will choose days.
  58. if(bantime >= 86401){
  59. realtime = days;
  60. };
  61. //this checks if it's over 604801 seconds(1 week and 1 second) it will choose weeks.
  62. if(bantime >= 604801){
  63. realtime = weeks;
  64. };
  65. //this is a just a joke :)
  66. if(bantime >= 31536001){
  67. realtime = years;
  68. };
  69. //=================================================================
  70. //end of converting the numbers from seconds to min, hours and days.
  71. //end of time variables
  72.  
  73. //verify if it's pm or AM
  74. let amORpm;
  75. if(hrs >= 0 && hrs <= 12){
  76. amORpm = "AM"
  77. }else{
  78. amORpm = "PM"
  79. };
  80.  
  81. let reason = args.slice(2).join(" ");
  82. if(!reason) reason = "No reason given!";
  83.  
  84. if(!message.guild.me.hasPermission(["BAN_MEMBERS", "ADMINISTRATOR"])) return message.channel.send("I don't have permissions to perform this!")
  85.  
  86. if(banMember.hasPermission("ADMINISTRATOR")) {
  87. return message.reply("I can't do that since he/she has more power than me.").then(sent => console.log(`${issuer.username} tried to use "!tempban" command on Object ID: ${userone}, ${idMember}, ACCESS: DENIED, REASON: He/She has Administrator permissions!`)).catch(console.error);
  88. }
  89. if(banMember.id === message.author.id){
  90. return message.reply(" You can't ban yourself.")
  91. }
  92. if(banMember.highestRole.position >= message.member.highestRole.position){
  93. return message.reply(` ${banMember} is higher rank than you.`)
  94. }
  95.  
  96.  
  97. message.delete();
  98.  
  99. Happy.bans[banMember.id] = {
  100. guild: message.guild.id,
  101. name: `<@${banMember.id}>`,
  102. Channel: message.channel.id,
  103. time: Date.now() + parseInt(args[1]) * 1000,
  104. Reason: reason,
  105. Date_and_Hour: TheDate+" || "+clock+" "+amORpm,
  106. }
  107. const modlog = message.guild.channels.find(channel => channel.name === 'mod-logs');
  108.  
  109. await fs.writeFile("./Storage/bans.json", JSON.stringify(Happy.bans, null,4), err =>{
  110. if(err) throw err;
  111. const banembed = new Discord.RichEmbed()
  112. .setAuthor(' Action | Temp-ban', `http://pluspng.com/img-png/thor-hammer-png--1600.png`)
  113. .addField('Moderator that issued the temp-ban: ', `${issuer}`,true)
  114. .addField('Member temp-banned: ', `<@${banMember.id}>`,true)
  115. .addField(`How much time got temp-banned?:`,`${bantime} seconds = (${realtime}) ${convertor}`,true)
  116. .addField('Reason of temp-ban: ', `${reason}`,true)
  117. .addField(`When it was temp-banned that person:`,TheDate+ " at "+ clock+" "+amORpm,true)
  118. .setColor('#D9D900')
  119. modlog.send(banembed)
  120.  
  121. })
  122.  
  123. await banMember.send(`Hello there, you have been banned from ${message.guild.name} for: ${reason}`).then(() =>
  124. message.guild.ban(banMember, { time: bantime, reason: reason})).catch(err => console.log(err));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement