Advertisement
3MoSteve

AntiLeave code

Dec 13th, 2020
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. const fs = require("fs");
  2. const leave = JSON.parse(fs.readFileSync("./leave.json", "utf-8"));
  3. const saveLeave = () => fs.writeFileSync("./leave.json", JSON.stringify(leave, null, 2));
  4. client.on("guildMemberRemove", (member) => {
  5. if (member.roles.cache.find(r => r.name.toLowerCase() == "muted")) {
  6. if (!leave[member.guild.id]) leave[member.guild.id] = [];
  7. leave[member.guild.id].push(member.user.id);
  8. saveLeave();
  9. }
  10. });
  11. client.on("guildMemberAdd", (member) => {
  12. if (leave[member.guild.id] && leave[member.guild.id].includes(member.user.id)) {
  13. let role = member.guild.roles.cache.find(r => r.name.toLowerCase() == "muted");
  14. if (role) member.roles.add(role, `This member left and rejoined the server to remvoe Mute role.`);
  15. }
  16. })
  17.  
  18. //By 3Mo_Steve | Toxic Codes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement