Advertisement
3MoSteve

Auto Role Voice

Jan 4th, 2021
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. const voice_roles = [{
  2. channel: "795661413246173204", //ايدي او اسم الروم
  3. role: "754332320273661962" //ايدي او اسم الرتبة
  4. },
  5. {
  6. channel: "Verified", //ايدي او اسم الروم
  7. role: "Verified" //ايدي او اسم الرتبة
  8. }
  9. ]
  10. client.on("voiceStateUpdate", (oldS, newS) => {
  11. if (oldS.channel == null && newS.channel !== null) {
  12. let setting = voice_roles.find(set => set.channel == newS.channelID || set.channel == newS.channel.name);
  13. if (!setting) return;
  14. let role = newS.guild.roles.cache.find(r => r.id == setting.role || r.name == setting.role);
  15. if (role) newS.member.roles.add(role, "Auto Voice Role (Join)");
  16. } else if (oldS.channel !== null && newS.channel == null) {
  17. let setting = voice_roles.find(set => set.channel == oldS.channelID);
  18. if (!setting) return;
  19. let role = newS.guild.roles.cache.find(r => r.id == setting.role || r.name == setting.role);
  20. if (role) newS.member.roles.remove(role, "Auto Voice Role (Leave)");
  21. oldS.channel.overwritePermissions([{
  22. id: oldS.member.id,
  23. deny: ["CONNECT"]
  24. }], "Prevent Spam (Auto Role.)").then((channel) => {
  25. setTimeout(() => {
  26. channel.permissionOverwrites.get(oldS.member.id).delete("Time out (Auto Role.)");
  27. }, 3000);
  28. })
  29. }
  30. });
  31.  
  32. //By 3Mo_Steve | Toxic Codes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement