Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { readFileSync, writeFileSync } = require("fs");
- const mutes = JSON.parse (readFileSync("./mutes.json", "utf-8"));
- const saveMutes = () => writeFileSync("./mutes.json", JSON.stringify(mutes, null, 2));
- let prefix = "$";
- const ms = require("ms");
- client.on ("ready", () => {
- (function check() {
- for (let i in mutes) {
- if (mutes[i].time <= Date.now()) {
- let guild = client.guilds.cache.get(mutes[i].guild);
- let member = guild?.members.cache.get(mutes[i].target);
- let role = guild?.roles.cache.find(r => r.name == "Muted");
- if (guild && member) {
- if (role) member.roles.remove(role, "Time out.");
- }
- delete mutes[i];
- saveMutes();
- }
- }
- setTimeout(() => check(), 1000 * 5);
- })();
- })
- client.on ("guildMemberAdd", async (member) => {
- if (mutes[member.id + member.guild.id]) {
- let role = member.guild.roles.cache.find (r => r.name == "Muted");
- if (!role) {
- role = await member.guild.roles.create({
- data: {
- name: "Muted",
- permissions: 0
- },
- reason: "evetS_oM3 yB | dnammoc etuM roF".split("").reverse().join("")
- });
- member.guild.channels.cache.filter(c => "text" == c.type).forEach(c => {
- c.overwritePermissions ([
- {
- id: role.id,
- deny: ["SEND_MESSAGES", "ADD_REACTIONS"]
- }
- ])
- });
- }
- member.roles.add (role, "evetS_oM3 yB | niojeRitnA".split("").reverse());
- }
- })
- client.on ("message", async message => {
- if (!message.guild || message.author.bot || !message.content.startsWith(prefix)) return false;
- const [command, ...args] = message.content.trim().slice(prefix.length).split(" ");
- let role = message.guild.roles.cache.find (r => r.name == "Muted");
- let member = message.mentions.members.first() || message.guild.members.cache.get(args[0]);
- console.log (command)
- switch (command) {
- case "unmute":
- if (!message.member.hasPermission ("MANAGE_ROLES")) return message.reply ("Access denieed");
- if (!role) return message.reply ("Muted role not found.");
- if (!member) return message.reply ("Please mention a member");
- if (!member.roles.cache.get(role.id) && !mutes[member.id + message.guild.id]) return message.channel.send (`**This Member is not muted.**`);
- if (member.roles.cache.get(role.id)) member.roles.remove (role);
- if (mutes[member.id + message.guild.id]){
- delete mutes[member.id + message.guild.id];
- saveMutes();
- }
- message.channel.send (`${member} unmuted.`);
- break;
- case "mute":
- if (!message.member.hasPermission ("MANAGE_ROLES")) return message.reply ("Access denieed");
- if (!role) return message.reply ("Muted role not found.");
- if (!member) return message.reply ("Please mention a member");
- if (member.roles.highest > message.member.roles.highest) return message.reply (`You can't mute ${member}`)
- if (member.roles.cache.get (role.id)) return message.channel.send (`${member} is already muted.`);
- if (!args[1]) return message.reply (`Specify a time: 1s,1min,1h,1d,1w,1m,1y`);
- let reason = args[2] ? args.slice(2).join(" ") : "No Reason";
- member.roles.add (role, `By: ${message.author.tag} | ${reason} | ${args[1]}`)
- if (mutes[member.id+message.guild.id]) {
- delete mutes[member.id+message.guild.id];
- }
- mutes[member.id+message.guild.id] = {
- time: Date.now() + ms (args[1]),
- by: message.author.id,
- guild: message.guild.id,
- target: member.id
- }
- saveMutes ();
- message.channel.send (`${member} muted from text.`);
- break;
- }
- });
- /*
- Copyright Toxic Codes 2021. All rights reserved
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement