Advertisement
3MoSteve

AntiLinks

Dec 4th, 2020 (edited)
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. const { readFileSync, writeFileSync } = require ("fs")
  2. const antilinks = JSON.parse (readFileSync("./antilinks.json", "utf-8"));
  3. const saveAnti = () => writeFileSync("./antilinks.json", JSON.stringify (antilinks, null, 2));
  4. client.on ("message", message => {
  5. if (!message.guild || message.author.bot) return;
  6. if (message.content.split(" ")[0] == "$antilinks") {
  7. if (!message.member.hasPermission ("MANAGE_GUILD")) return message.reply ("Access denied");
  8. const st = message.content.split(" ")[1];
  9. if (!st || !["on", "off"].includes (st)) return message.channel.send (`$antilinks on/off`);
  10. antilinks[message.guild.id] = {
  11. status: (st == "on" ? true : false)
  12. }
  13. saveAnti();
  14. message.channel.send (`Successfully ${(st == "on" ? "Enabled" : "Disabled")} AntiLinks.`);
  15. }
  16. })
  17. client.on("message", message => {
  18. if (!message.guild || message.author.bot || !message.member.hasPermission("MANAGE_GUILD") || !antilinks[message.guild.id] || !antilinks[message.guild.id].status) return false;
  19. if (/^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/.test (message.content.toLowerCase())) {
  20. message.delete ();
  21. message.channel.send (`**Do not share links.**`);
  22. }
  23. })
  24. //By 3Mo_Steve | Toxic Codes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement