Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //time variables
- var clock = new Date();
- var ss = String(clock.getSeconds()).padStart(2, '0');
- var min = String(clock.getMinutes()).padStart(2, '0');
- var hrs = String(clock.getHours()).padStart(1, '0');
- clock = hrs + ':' + min +':' + ss;
- var TheDate = new Date()
- var zilelesaptamanii = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
- var weekday = zilelesaptamanii[TheDate.getDay()];
- var dd = String(TheDate.getDate()).padStart(2, '0');
- var mon = String(TheDate.getMonth()+ 1);
- var year = String(TheDate.getFullYear()).padStart(4,'00');
- TheDate = weekday+", " + mon + '/' + dd +'/' + year;
- //end of time variables
- //verify if it's pm or AM
- let amORpm;
- if(hrs >= 0 && hrs <= 12){
- amORpm = "AM"
- }else{
- amORpm = "PM"
- };
- const modlog = message.guild.channels.find(channel => channel.name === 'mod-logs');
- let toMute = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
- let user1 = message.guild.member(message.mentions.users.first())+`, DISCRIMINATORY ID: #${message.mentions.users.first().discriminator}`;
- let role = message.guild.roles.find(r => r.name === "muted");
- var egal = "**|===================================================================**"
- var REQ1 = "**|** 1)`The person you're trying to mute has Administrator permission.` **|**";
- var REQ2 = "**|** 2)`The person you're trying to mute has the same rank like your or higher than yours!` **|**";
- var endSen = "When you verified if those 2 requirements are not met, try again.";
- //if he didn't mentioned anyone, send that message
- if (!toMute) {
- return message.reply(` I couldn't find that person!`)};
- //if that person has Administrator permission, don't do it
- if(toMute.hasPermission("ADMINISTRATOR") || toMute.highestRole.position >= message.member.highestRole.position) {
- return message.reply(`I can't do this because of 2 reasons:
- ${egal}
- ${REQ1}
- ${REQ2}
- ${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)};
- //if the issuer want to mute himself :)) , you can't do that :))
- if(toMute.id === message.author.id){ return message.reply(" You can simply don't talk if you really want to mute yourself.")};
- if(toMute.highestRole.position >= message.member.highestRole.position){
- return message.reply(` ${toMute} is higher rank than you.`)
- }
- //if the role doesn't exist, create it.
- if (!role) {
- try {
- muterole = await message.guild.createRole({
- name: "Muted",
- color: "#000000",
- permissions: []
- })
- message.guild.channels.forEach(async (channel, id) => {
- await channel.overwritePermissions(role, {
- SEND_MESSAGES: false,
- ADD_REACTIONS: false,
- SEND_TTS_MESSAGES: false,
- ATTACH_FILES: false,
- SPEAK: false
- });
- });
- } catch (e) {
- console.log(e.stack);
- }
- }
- let mutetime = args[1];
- if (!mutetime) return message.reply("tell me how much time you want him to not talk!");
- //converts in min/hrs and days text
- let convertor;
- //converts from secoonds to min, otherwise if it's lower than 1 min, it will show seconds
- if(mutetime >= 61 && mutetime <= 3599){
- convertor = "minutes"
- }else{
- convertor = "seconds"
- };
- //converts from seconds to hours, otherwise if it's lower than 1 hour it will display minutes
- if(mutetime >= 3601 && mutetime <= 86399){
- convertor = "hours"
- };
- //converts from seconds to days otherwise if it's lower than 1 day it will show hours
- if(mutetime > 86401){
- convertor = "days"
- };
- //converts from seconds to weeks otherwise if it's lower than 1 week it will show days
- if(mutetime > 604801){
- convertor = "weeks"
- }
- //this is just a joke :)
- if(mutetime > 31536001){
- convertor = "years";
- }
- //end of converting
- //converts the numbers from seconds to min, hours and days and weeks because why not
- var minutes = (mutetime / 60);
- var hours = (mutetime/3600);
- var days = (mutetime/86400);
- var weeks = (mutetime/604800);
- var years = (mutetime/31536000);
- //now time to choose carefully what to take and what to not
- //this checks if it's over 60 seconds and lower or equal with 3600 seconds, it will choose minutes var.
- let realtime;
- if(mutetime > 60 && mutetime <= 3600){
- realtime = minutes;
- };
- //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.
- if(mutetime >=3601 && mutetime <= 86400){
- realtime = hours;
- };
- //this checks if it's over 86401 seconds(1 day and 1 second) it will choose days.
- if(mutetime >= 86401){
- realtime = days;
- };
- //this checks if it's over 604801 seconds(1 week and 1 second) it will choose weeks.
- if(mutetime >= 604801){
- realtime = weeks;
- };
- //this is a just a joke :)
- if(mutetime >= 31536001){
- realtime = years;
- };
- //=================================================================
- //end of converting the numbers from seconds to min, hours and days.
- let reason = args.slice(2).join(" ");
- //message.content.split(/ +/).slice(2).join(" ");
- if (!reason) return message.channel.send('Please specify a reason for the mute!')
- if(toMute.roles.find(role => role.name === `muted`)) return message.channel.send(`${toMute} is already muted, ${issuer}.`)
- Happy.mutes[toMute.id] = {
- guild: message.guild.id,
- name: `<@${toMute.id}>`,
- Channel: message.channel.id,
- time: Date.now() + parseInt(args[1]) * 1000,
- Reason: reason,
- Date_and_Hour: TheDate+" || "+clock+" "+amORpm,
- }
- await toMute.addRole(role);
- fs.writeFile("./Storage/mutes.json", JSON.stringify(Happy.mutes, null,4), err =>{
- if(err) throw err;
- const muteembed = new Discord.RichEmbed()
- .setAuthor(' Action | Mute', `https://images-ext-2.discordapp.net/external/Wms63jAyNOxNHtfUpS1EpRAQer2UT0nOsFaWlnDdR3M/https/image.flaticon.com/icons/png/128/148/148757.png`)
- .addField('Moderator that issued the mute: ', `${issuer}`,true)
- .addField('Member muted: ', `<@${toMute.id}>`,true)
- .addField(`How much time got muted?:`,`${mutetime} seconds = (${realtime}) ${convertor}`,true)
- .addField('Reason of mute: ', `${reason}`,true)
- .addField(`When it was muted that person:`,TheDate+ " at "+ clock+" "+amORpm,true)
- .setColor('#D9D900')
- modlog.send(muteembed)
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement