Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let banMember = message.mentions.members.first() || message.guild.members.get(args[0]);
- if(!banMember) return message.channel.send("Please provide a member to ban!");
- let userone = message.guild.member(message.mentions.users.first());
- let idMember = `DISCRIMINATORY ID: #${message.mentions.users.first().discriminator}`;
- var issuer = message.author;
- 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);
- //converts in min/hrs and days text
- let convertor;
- let bantime = args[1];
- if (!bantime) return message.reply("tell me how much time you want the member mentioned to be banned!");
- //converts from secoonds to min, otherwise if it's lower than 1 min, it will show seconds
- if(bantime >= 61 && bantime <= 3599){
- convertor = "minutes"
- }else{
- convertor = "seconds"
- };
- //converts from seconds to hours, otherwise if it's lower than 1 hour it will display minutes
- if(bantime >= 3601 && bantime <= 86399){
- convertor = "hours"
- };
- //converts from seconds to days otherwise if it's lower than 1 day it will show hours
- if(bantime > 86401){
- convertor = "days"
- };
- //converts from seconds to weeks otherwise if it's lower than 1 week it will show days
- if(bantime > 604801){
- convertor = "weeks"
- }
- //this is just a joke :)
- if(bantime > 31536001){
- convertor = "years";
- }
- //end of converting
- //converts the numbers from seconds to min, hours and days and weeks because why not
- var minutes = (bantime / 60);
- var hours = (bantime/3600);
- var days = (bantime/86400);
- var weeks = (bantime/604800);
- var years = (bantime/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(bantime > 60 && bantime <= 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(bantime >=3601 && bantime <= 86400){
- realtime = hours;
- };
- //this checks if it's over 86401 seconds(1 day and 1 second) it will choose days.
- if(bantime >= 86401){
- realtime = days;
- };
- //this checks if it's over 604801 seconds(1 week and 1 second) it will choose weeks.
- if(bantime >= 604801){
- realtime = weeks;
- };
- //this is a just a joke :)
- if(bantime >= 31536001){
- realtime = years;
- };
- //=================================================================
- //end of converting the numbers from seconds to min, hours and days.
- //end of time variables
- //verify if it's pm or AM
- let amORpm;
- if(hrs >= 0 && hrs <= 12){
- amORpm = "AM"
- }else{
- amORpm = "PM"
- };
- let reason = args.slice(2).join(" ");
- if(!reason) reason = "No reason given!";
- if(!message.guild.me.hasPermission(["BAN_MEMBERS", "ADMINISTRATOR"])) return message.channel.send("I don't have permissions to perform this!")
- if(banMember.hasPermission("ADMINISTRATOR")) {
- 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);
- }
- if(banMember.id === message.author.id){
- return message.reply(" You can't ban yourself.")
- }
- if(banMember.highestRole.position >= message.member.highestRole.position){
- return message.reply(` ${banMember} is higher rank than you.`)
- }
- message.delete();
- Happy.bans[banMember.id] = {
- guild: message.guild.id,
- name: `<@${banMember.id}>`,
- Channel: message.channel.id,
- time: Date.now() + parseInt(args[1]) * 1000,
- Reason: reason,
- Date_and_Hour: TheDate+" || "+clock+" "+amORpm,
- }
- const modlog = message.guild.channels.find(channel => channel.name === 'mod-logs');
- await fs.writeFile("./Storage/bans.json", JSON.stringify(Happy.bans, null,4), err =>{
- if(err) throw err;
- const banembed = new Discord.RichEmbed()
- .setAuthor(' Action | Temp-ban', `http://pluspng.com/img-png/thor-hammer-png--1600.png`)
- .addField('Moderator that issued the temp-ban: ', `${issuer}`,true)
- .addField('Member temp-banned: ', `<@${banMember.id}>`,true)
- .addField(`How much time got temp-banned?:`,`${bantime} seconds = (${realtime}) ${convertor}`,true)
- .addField('Reason of temp-ban: ', `${reason}`,true)
- .addField(`When it was temp-banned that person:`,TheDate+ " at "+ clock+" "+amORpm,true)
- .setColor('#D9D900')
- modlog.send(banembed)
- })
- await banMember.send(`Hello there, you have been banned from ${message.guild.name} for: ${reason}`).then(() =>
- message.guild.ban(banMember, { time: bantime, reason: reason})).catch(err => console.log(err));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement