Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { readFileSync, writeFileSync } = require("fs")
- const muted = JSON.parse(readFileSync("./muted.json", "utf-8"));
- const ms = require("ms");
- const saveMuted = () => writeFileSync("./muted.json", JSON.stringify(muted, null, 2));
- //Code By 3Mo_Steve | Toxic Codes
- client.on("ready", () => {
- setInterval(() => {
- for (let i in muted) {
- if (muted[i].time <= Date.now()) {
- const guild = client.guilds.cache.get(muted[i].guild);
- const member = guild.members.cache.get(muted[i].member);
- const role = guild.roles.cache.find(r => r.name == "Muted");
- if (role) member.roles.remove(role);
- delete muted[i];
- saveMuted();
- }
- }
- }, 1000 * 5);
- });
- //Time formats:
- //1y = 1 Year
- //1m = 1 Month
- //1w = 1 Week
- //1d = 1 Day
- //1h = 1 Hour
- //1min = 1 Minute
- //1s = 1 second
- const reasons = [{
- "reason": "سب",
- "time": "5h"
- },
- {
- "reason": "سبام بلشات",
- "time": "10s"
- },
- {
- "reason": "مدري",
- "time": "1m"
- }
- ]
- client.on("message", message => {
- if (!message.guild || message.author.bot) return false;
- const args = message.content.split(" ");
- if (args[0] == "$mute") {
- if (!message.member.hasPermission ("MANAGE_ROLES")) return message.reply ("Access denied");
- const member = message.mentions.members.first();
- if (!member || (args[2] && !args[3])) return message.channel.send(`**Usage: ${args[0]} <mention>\nOr: ${args[0]} <mention> <time> <reason>**`);
- const role = message.guild.roles.cache.find(r => r.name == "Muted");
- if (!role) return message.reply("I can't find **Muted** role.");
- if (!args[2]) {
- if (reasons.length == 0) return message.reply(`There is no default reason please provide the time and reason.`);
- var i = 1;
- const embed = new MessageEmbed()
- .setColor("GREEN")
- .setTitle(`Select a reason`)
- .setDescription(`${reasons.map (re => `**${i++}** - ${re.reason}: ${re.time}`).join("\n")}`)
- .setThumbnail(message.author.displayAvatarURL())
- .setTimestamp().setFooter(`By: 3Mo_Steve`)
- message.channel.send(embed).then(msg => {
- message.channel.awaitMessages((m => m.author.id == message.author.id && !isNaN(m.content) && parseInt(m.content) > 0 && parseInt(m.content) < reasons.length), {
- max: 1,
- time: 1000 * 60,
- errors: ["time"]
- }).then(collected => {
- const {
- reason,
- time
- } = reasons[(parseInt(collected.first().content) - 1)];
- muted[member.user.id] = {
- mod: message.author.id,
- member: member.user.id,
- guild: message.guild.id,
- reason,
- time: Date.now() + ms(time)
- }
- saveMuted();
- message.channel.send(`${member} muted from text.`);
- member.roles.add(role, `By: ${message.author.tag} | ${reason}`)
- }).catch(e => {
- console.log(e)
- msg.delete();
- message.reply(`Time out.`);
- })
- })
- } else {
- muted[member.user.id] = {
- mod: message.author.id,
- member: member.user.id,
- guild: message.guild.id,
- reason: args.slice(3).join(" "),
- time: Date.now() + ms(args[2])
- }
- saveMuted();
- member.roles.add(role, `By: ${message.author.tag} | ${args.slice(3).join(" ")}`)
- message.channel.send(`${member} muted from text.`);
- }
- }
- });
- client.on ("guildMemberAdd", (toxic) => {
- if (toxic.user.bot || !muted[toxic.user.id]) return;
- if (muted[toxic.user.id].time < Date.now()) {
- const role = toxic.guild.roles.cache.find (r => r.name == "Muted");
- if (role) toxic.roles.add (role);
- }
- }); //منشان ازا طلع من السيرفر ودخل
- //By 3Mo_Steve | Toxic Codes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement