Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (command === "mute") {
- if (!message.member.hasPermission("MANAGE_ROLES") || !message.guild.owner) return message.channel.send("You dont have permission to use this command.");
- if (!message.guild.me.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"])) return message.channel.send("I don't have permission to add roles!")
- //define the reason and mutee
- let mutee = message.mentions.members.first() || message.guild.members.get(args[0]);
- if (!mutee) return message.channel.send("Please mention a user to be muted!");
- let reason = args.slice(1).join(" ");
- if (!reason) reason = "No reason given"
- //define mute role and if the mute role doesnt exist then create one
- let muterole = message.guild.roles.find(r => r.name === "Muted")
- if (!muterole) {
- try {
- muterole = await message.guild.createRole({
- name: "Muted",
- color: "#514f48",
- permissions: []
- })
- message.guild.channels.forEach(async (channel, id) => {
- await channel.overwritePermissions(muterole, {
- SEND_MESSAGES: false,
- ADD_REACTIONS: false,
- SEND_TTS_MESSAGES: false,
- ATTACH_FILES: false,
- SPEAK: false
- })
- })
- } catch (e) {
- console.log(e.stack);
- }
- }
- //add role to the mentioned user and also send the user a dm explaing where and why they were muted
- mutee.addRole(muterole.id).then(() => {
- message.delete()
- mutee.send(`Hello, you have been muted in ${message.guild.name} for: ${reason}`).catch(err => console.log(err))
- message.channel.send(`${mutee.user.username} was successfully muted.`)
- })
- if (command === "unmute") {
- if (!message.member.hasPermission("MANAGE_ROLES") || !message.guild.owner) return message.channel.send("You dont have permission to use this command.");
- if (!message.guild.me.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"])) return message.channel.send("I don't have permission to add roles!")
- //define the reason and unmutee
- let mutee = message.mentions.members.first() || message.guild.members.get(args[0]);
- if (!mutee) return message.channel.send("Please mention a user to be muted!");
- let reason = args.slice(1).join(" ");
- if (!reason) reason = "No reason given"
- //define mute role and if the mute role doesnt exist then send a message
- let muterole = message.guild.roles.find(r => r.name === "Muted")
- if (!muterole) return message.channel.send("That user is muted.")
- //remove role to the mentioned user and also send the user a dm explaing where and why they were unmuted
- mutee.removeRole(muterole.id).then(() => {
- message.delete()
- message.channel.send(`${mutee.user.username} was unmuted!`)
- })
- //send an embed to the modlogs channel
- let unmuteembed = new Discord.RichEmbed()
- .setColor(colors.redlight)
- .setAuthor(`${message.guild.name} Modlogs`, message.guild.iconURL)
- .addField("Moderation:", "unmute")
- .addField("Person who was moderated:", mutee.user.username)
- .addField("Moderator:", message.author.username)
- .addField("Reason:", reason)
- .addField("Date:", message.createdAt.toLocaleString())
- let sChannel = message.guild.channels.find(c => c.name === "logs")
- sChannel.send(unmuteembed)
- }
- if (command === "unban") {
- if (!message.member.hasPermission(["BAN_MEMBERS", "ADMINISTRATOR"])) return message.channel.send("You dont have permission to perform this command!")
- if (isNaN(args[0])) return message.channel.send("You need to provide an ID.")
- let bannedMember = await client.fetchUser(args[0])
- if (!bannedMember) return message.channel.send("Please provide a user id to unban someone!")
- let reason = args.slice(1).join(" ")
- if (!reason) reason = "No reason given!"
- if (!message.guild.me.hasPermission(["BAN_MEMBERS", "ADMINISTRATOR"])) return message.channel.send("I dont have permission to perform this command!") |
- message.delete()
- try {
- message.guild.unban(bannedMember, reason)
- message.channel.send(`${bannedMember.tag} has been unbanned from the guild!`)
- } catch (e) {
- console.log(e.message)
- }
- let unbannedembed = new Discord.RichEmbed()
- .setColor("random")
- .setAuthor(`${message.guild.name} Modlogs`, message.guild.iconURL)
- .addField("Moderation:", "unban")
- .addField("Moderated on:", `${bannedMember.username} (${bannedMember.id})`)
- .addField("Moderator:", message.author.username)
- .addField("Reason:", reason)
- .addField("Date:", message.createdAt.toLocaleString())
- let sChannel = message.guild.channels.find(c => c.name === "logs")
- sChannel.send(unbannedembed)
- }
- if (command === "ban") {
- //embeds, here.
- let noperms = new Discord.RichEmbed()
- .setTitle(`Error`)
- .setDescription(`You Do not have permissions to ban people.`)
- .setTimestamp()
- .setFooter("Sparky", client.user.avatarURL)
- let nomember = new Discord.RichEmbed()
- .setTitle(`Error`)
- .setDescription('You did not mention a member to ban.')
- .setFooter("Sparky", client.user.avatarURL)
- .setTimestamp()
- //https://support.discordapp.com/hc/article_attachments/115001756911/Administrator__1_.jpg
- const bothasnoperms = new Discord.RichEmbed()
- .setTitle(`Error`)
- .addField(`I do not have ban permissions.`, `i need the permission below.`)
- .setImage("https://i.imgur.com/t6NGqwR.png")
- .setTimestamp()
- .setFooter("Sparky", client.user.avatarURL)
- let icannotbanthem = new Discord.RichEmbed()
- .setTitle(`Error`)
- .setDescription(`I cannot ban this member! they might have a higher role than me or i don't have ban permissions.`)
- .setTimestamp()
- .setFooter("Sparky", client.user.avatarURL)
- const modlogs = client.channels.get("603746848964083752");
- // Most of this command is identical to kick, except that here we'll only let admins do it.
- // In the real world mods could ban too, but this is just an example, right? ;)
- if (!message.guild.me.hasPermission("BAN_MEMBERS")) return message.channel.send(bothasnoperms)
- if (!message.member.hasPermission("BAN_MEMBERS")) return message.channel.send(noperms)
- let member = message.mentions.members.first();
- if (!member) return message.channel.send(erroremoji + "Please mention a member.")
- if (member.hasPermission("ADMINISTRATOR")) {
- message.channel.send(erroremoji + "That user is a mod/admin, I cannot ban them.")
- } else {
- if (!member.bannable)
- return message.channel.send(erroremoji + "I cannot ban this user! ");
- let reason = args.slice(1).join(' ');
- if (!reason) reason = "No reason provided";
- await member.ban(reason)
- .catch(error => message.channel.send(erroremoji + `Sorry ${message.author} I couldn't ban because of : ${error}`));
- message.channel.send(successemoji + `${member}` + "was successfully banned.");
- }
- }
- if (command === "tempmute") {
- if (!message.member.hasPermission("MANAGE_MESSAGES")) return message.reply("You dont have permission to use this command.");
- let tomute = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
- if (!tomute) return message.reply("Please mention a user.");
- if (tomute.hasPermission("MANAGE_MESSAGES")) return message.reply("Can't mute them!");
- let reason = args.slice(2).join(" ");
- if (!reason) reason = "no reason provided"
- let muterole = message.guild.roles.find(`name`, "Muted");
- //start of create role
- if (!muterole) {
- try {
- muterole = await message.guild.createRole({
- name: "muted",
- color: "#000000",
- permissions: []
- })
- message.guild.channels.forEach(async (channel, id) => {
- await channel.overwritePermissions(muterole, {
- SEND_MESSAGES: false,
- ADD_REACTIONS: false
- });
- });
- } catch (e) {
- console.log(e.stack);
- }
- }
- //end of create role
- let mutetime = args[1];
- if (!mutetime) return message.reply("You didn't specify a time!");
- message.delete().catch(O_o => {});
- try {
- await tomute.send(`Hi! You've been muted for ${mutetime}. Sorry!`)
- } catch (e) {
- message.channel.send(`A user has been muted... but their DMs are locked. They will be muted for ${mutetime}`)
- }
- let muteembed = new Discord.RichEmbed()
- .setDescription(`Mute executed by ${message.author}`)
- .setColor("#eb9b34")
- .addField("Muted User", tomute)
- .addField("Muted in", message.channel)
- .addField("Time", message.createdAt)
- .addField("Length", mutetime)
- .addField("Reason", reason);
- let channel = message.guild.channels.find(c => c.name === "logs");
- if (!channel) return message.reply("Please create a channel named 'logs'.");
- channel.send(muteembed);
- await (tomute.addRole(muterole.id));
- let mutemebed = new Discord.RichEmbed()
- .setTitle('Mute')
- .setDescription(`${tomute} was muted by ${message.author} because: ${reason} gg`)
- .setFooter("Sparky", client.user.avatarURL)
- .setColor("#00ff00")
- message.channel.send(mutemebed)
- setTimeout(function () {
- tomute.removeRole(muterole.id);
- }, ms(mutetime));
- }
- if (command === "addrole") {
- let idonthaveperms = new Discord.RichEmbed()
- .setTitle('Error')
- .setDescription('I don\'t have the following permission needed to add roles: `MANAGE_ROLES`, or `ADMINISTRATOR`.')
- .setFooter("Sparky", client.user.avatarURL)
- .setColor("#00ff00")
- let erroremoji = "<:errormate:609298253565001738>"
- if (!message.member.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"])) return message.channel.send("You dont have permission to perform this command!")
- let rMember = message.mentions.members.first() || message.guild.members.find(m => m.user.tag === args[0]) || message.guild.members.get(args[0])
- if (!rMember) return message.channel.send("Please provide a user to add a role too.")
- let role = message.guild.roles.find(r => r.name == args[1]) || message.guild.roles.find(r => r.id == args[1]) || message.mentions.roles.first()
- if (!role) return message.channel.send("Please provide a role to add to said user.")
- let reason = args.slice(2).join(" ")
- if (!reason) reason = "no reason provided"
- if (!message.guild.me.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"])) return message.channel.send(idonthaveperms)
- if (rMember.roles.has(role.id)) {
- return message.channel.send(`${rMember.displayName}, already has the role!`)
- } else {
- await rMember.addRole(role.id).catch(e => console.log(e.message))
- message.channel.send(`The role, ${role.name}, has been added to ${rMember.displayName}.`)
- }
- let addroleembed = new RichEmbed()
- .setColor(redlight)
- .setAuthor(`${message.guild.name} Modlogs`, message.guild.iconURL)
- .addField("Moderation:", "Addrole")
- .addField("Person who was moderated:", rMember.user.username)
- .addField("Moderator:", message.author.username)
- .addField("Reason:", reason)
- .addField("Date:", message.createdAt.toLocaleString())
- let sChannel = message.guild.channels.find(c => c.name === "logs")
- sChannel.send(addroleembed)
- }
- if (command === "removerole") {
- if (!message.member.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"])) return message.channel.send("You dont have permission to perform this command!")
- let rMember = message.mentions.members.first() || message.guild.members.find(m => m.user.tag === args[0]) || message.guild.members.get(args[0])
- if (!rMember) return message.channel.send("Please provide a user to remove a role too.")
- let role = message.guild.roles.find(r => r.name == args[1]) || message.guild.roles.find(r => r.id == args[1]) || message.mentions.roles.first()
- if (!role) return message.channel.send("Please provide a role to remove from said user.")
- let reason = args.slice(2).join(" ")
- if (!reason) reason = "no reason provided"
- if (!message.guild.me.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"])) return message.channel.send("I don't have permission to perform this command.")
- if (!rMember.roles.has(role.id)) {
- return message.channel.send(`${rMember.displayName}, doesnt have the role!`)
- } else {
- await rMember.removeRole(role.id).catch(e => console.log(e.message))
- message.channel.send(`The role, ${role.name}, has been removed from ${rMember.displayName}.`)
- }
- let removeroleembed = new Discord.RichEmbed()
- .setColor(redlight)
- .setAuthor(`${message.guild.name} Modlogs`, message.guild.iconURL)
- .addField("Moderation:", "Addrole")
- .addField("Person who was moderated", rMember.user.username)
- .addField("Moderator:", message.author.username)
- .addField("Reason:", reason)
- .addField("Date:", message.createdAt.toLocaleString())
- let sChannel = message.guild.channels.find(c => c.name === "logs")
- sChannel.send(removeroleembed)
- }
Advertisement
Add Comment
Please, Sign In to add comment