Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.18 KB | None | 0 0
  1. //time variables
  2. var clock = new Date();
  3. var ss = String(clock.getSeconds()).padStart(2, '0');
  4. var min = String(clock.getMinutes()).padStart(2, '0');
  5. var hrs = String(clock.getHours()).padStart(1, '0');
  6. clock = hrs + ':' + min +':' + ss;
  7.  
  8. var TheDate = new Date()
  9. var zilelesaptamanii = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
  10. var weekday = zilelesaptamanii[TheDate.getDay()];
  11. var dd = String(TheDate.getDate()).padStart(2, '0');
  12. var mon = String(TheDate.getMonth()+ 1);
  13. var year = String(TheDate.getFullYear()).padStart(4,'00');
  14. TheDate = weekday+", " + mon + '/' + dd +'/' + year;
  15. //end of time variables
  16.  
  17. //verify if it's pm or AM
  18. let amORpm;
  19. if(hrs >= 0 && hrs <= 12){
  20. amORpm = "AM"
  21. }else{
  22. amORpm = "PM"
  23. };
  24.  
  25. const modlog = message.guild.channels.find(channel => channel.name === 'mod-logs');
  26. let toMute = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
  27. let user1 = message.guild.member(message.mentions.users.first())+`, DISCRIMINATORY ID: #${message.mentions.users.first().discriminator}`;
  28. let role = message.guild.roles.find(r => r.name === "muted");
  29. var egal = "**|===================================================================**"
  30. var REQ1 = "**|** 1)`The person you're trying to mute has Administrator permission.` **|**";
  31. var REQ2 = "**|** 2)`The person you're trying to mute has the same rank like your or higher than yours!` **|**";
  32. var endSen = "When you verified if those 2 requirements are not met, try again.";
  33. //if he didn't mentioned anyone, send that message
  34. if (!toMute) {
  35. return message.reply(` I couldn't find that person!`)};
  36.  
  37. //if that person has Administrator permission, don't do it
  38. if(toMute.hasPermission("ADMINISTRATOR") || toMute.highestRole.position >= message.member.highestRole.position) {
  39. return message.reply(`I can't do this because of 2 reasons:
  40. ${egal}
  41. ${REQ1}
  42. ${REQ2}
  43. ${egal}\n\n${endSen}`).then(sent => console.log(` ${issuer.username} tried to use "!mute" command on Object ID: ${user1} , ACCESS: DENIED, REASON: He/She has Administrator permissions or equally/higher role than ${Happy.user.username}/${issuer.username}!`)).catch(console.error)};
  44. //if the issuer want to mute himself :)) , you can't do that :))
  45. if(toMute.id === message.author.id){ return message.reply(" You can simply don't talk if you really want to mute yourself.")};
  46. if(toMute.highestRole.position >= message.member.highestRole.position){
  47. return message.reply(` ${toMute} is higher rank than you.`)
  48. }
  49.  
  50.  
  51.  
  52.  
  53.  
  54. //if the role doesn't exist, create it.
  55. if (!role) {
  56. try {
  57. muterole = await message.guild.createRole({
  58. name: "Muted",
  59. color: "#000000",
  60. permissions: []
  61. })
  62. message.guild.channels.forEach(async (channel, id) => {
  63. await channel.overwritePermissions(role, {
  64. SEND_MESSAGES: false,
  65. ADD_REACTIONS: false,
  66. SEND_TTS_MESSAGES: false,
  67. ATTACH_FILES: false,
  68. SPEAK: false
  69. });
  70. });
  71. } catch (e) {
  72. console.log(e.stack);
  73. }
  74. }
  75. let mutetime = args[1];
  76. if (!mutetime) return message.reply("tell me how much time you want him to not talk!");
  77.  
  78. //converts in min/hrs and days text
  79. let convertor;
  80.  
  81. //converts from secoonds to min, otherwise if it's lower than 1 min, it will show seconds
  82. if(mutetime >= 61 && mutetime <= 3599){
  83. convertor = "minutes"
  84. }else{
  85. convertor = "seconds"
  86. };
  87. //converts from seconds to hours, otherwise if it's lower than 1 hour it will display minutes
  88. if(mutetime >= 3601 && mutetime <= 86399){
  89. convertor = "hours"
  90. };
  91. //converts from seconds to days otherwise if it's lower than 1 day it will show hours
  92. if(mutetime > 86401){
  93. convertor = "days"
  94. };
  95. //converts from seconds to weeks otherwise if it's lower than 1 week it will show days
  96. if(mutetime > 604801){
  97. convertor = "weeks"
  98. }
  99. //this is just a joke :)
  100. if(mutetime > 31536001){
  101. convertor = "years";
  102. }
  103. //end of converting
  104.  
  105. //converts the numbers from seconds to min, hours and days and weeks because why not
  106. var minutes = (mutetime / 60);
  107. var hours = (mutetime/3600);
  108. var days = (mutetime/86400);
  109. var weeks = (mutetime/604800);
  110. var years = (mutetime/31536000);
  111. //now time to choose carefully what to take and what to not
  112. //this checks if it's over 60 seconds and lower or equal with 3600 seconds, it will choose minutes var.
  113. let realtime;
  114. if(mutetime > 60 && mutetime <= 3600){
  115. realtime = minutes;
  116. };
  117. //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.
  118. if(mutetime >=3601 && mutetime <= 86400){
  119. realtime = hours;
  120. };
  121. //this checks if it's over 86401 seconds(1 day and 1 second) it will choose days.
  122. if(mutetime >= 86401){
  123. realtime = days;
  124. };
  125. //this checks if it's over 604801 seconds(1 week and 1 second) it will choose weeks.
  126. if(mutetime >= 604801){
  127. realtime = weeks;
  128. };
  129. //this is a just a joke :)
  130. if(mutetime >= 31536001){
  131. realtime = years;
  132. };
  133. //=================================================================
  134. //end of converting the numbers from seconds to min, hours and days.
  135.  
  136. let reason = args.slice(2).join(" ");
  137. //message.content.split(/ +/).slice(2).join(" ");
  138. if (!reason) return message.channel.send('Please specify a reason for the mute!')
  139.  
  140. if(toMute.roles.find(role => role.name === `muted`)) return message.channel.send(`${toMute} is already muted, ${issuer}.`)
  141.  
  142. Happy.mutes[toMute.id] = {
  143. guild: message.guild.id,
  144. name: `<@${toMute.id}>`,
  145. Channel: message.channel.id,
  146. time: Date.now() + parseInt(args[1]) * 1000,
  147. Reason: reason,
  148. Date_and_Hour: TheDate+" || "+clock+" "+amORpm,
  149.  
  150.  
  151. }
  152. await toMute.addRole(role);
  153. fs.writeFile("./Storage/mutes.json", JSON.stringify(Happy.mutes, null,4), err =>{
  154. if(err) throw err;
  155. const muteembed = new Discord.RichEmbed()
  156. .setAuthor(' Action | Mute', `https://images-ext-2.discordapp.net/external/Wms63jAyNOxNHtfUpS1EpRAQer2UT0nOsFaWlnDdR3M/https/image.flaticon.com/icons/png/128/148/148757.png`)
  157. .addField('Moderator that issued the mute: ', `${issuer}`,true)
  158. .addField('Member muted: ', `<@${toMute.id}>`,true)
  159. .addField(`How much time got muted?:`,`${mutetime} seconds = (${realtime}) ${convertor}`,true)
  160. .addField('Reason of mute: ', `${reason}`,true)
  161. .addField(`When it was muted that person:`,TheDate+ " at "+ clock+" "+amORpm,true)
  162. .setColor('#D9D900')
  163. modlog.send(muteembed)
  164.  
  165. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement