Advertisement
Naomiora

Untitled

Jul 17th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   if (action === "add") {
  2.     var user = args[1];
  3.     if (!user) return message.reply("Please include a roblox username.");
  4.     if (user.replace(/[^a-z^0-9^_]/ig, "") !== user) return message.reply("I'm not stupid >;c please include a valid roblox username.");
  5.     var rows = await sql.all(`SELECT * FROM gameBans WHERE LOWER(user) = "${user.toLowerCase()}"`);
  6.     if(!rows[0]) {
  7.       var reason = message.content.toLowerCase().includes("proof:") ? args.slice(2, args.findIndex(i => i.toLowerCase() === "proof:")).join(" ") : args.slice(2).join(" ");
  8.       if(!reason) return message.reply("Please include a reason.");
  9.       var int = args.findIndex(i => i.toLowerCase() === "proof:") + 1;
  10.       var proof = message.content.toLowerCase().includes("duration:") ? args.slice(args.findIndex(i => i.toLowerCase() === "proof:") + 1, args.findIndex(i => i.toLowerCase() === "duration:")).join(" ") : args.slice(args.findIndex(i => i.toLowerCase() === "proof:") + 1).join(" ");
  11.       if(!proof) return message.reply("Please include proof.");
  12.       if(proof.toLowerCase().includes("cdn.discordapp.com/attachments/")) return message.reply("Please don't use discord attachment links as proof. Upload it to for example imgur.");
  13.       if(message.content.toLowerCase().includes("duration:")) {
  14.        
  15.       } else {
  16.         sql.run("INSERT INTO gameBans (user, moderator, guildId, reason, proof, dateBan, dateUnban, unbanSentToRoblox, perm) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", [user, message.author.id, message.guild.id, reason, proof, Date(), 0, 0, 1]);
  17.         message.reply("This ban has succesfully been logged into the registry.");
  18.       }
  19.     } else return message.reply("This user is already banned, doofus.");
  20.   } else if (action === "check") {
  21.     var user = args[1];
  22.     if (!user) return message.reply("Please include a roblox username.");
  23.     if (user.replace(/[^a-z^0-9^_]/ig, "") !== user) return message.reply("I'm not stupid >;c please include a valid roblox username.");
  24.     var rows = await sql.all(`SELECT * FROM gameBans WHERE LOWER(user) = "${user.toLowerCase()}"`);
  25.     if(rows[0]) {
  26.       var moderator = await client.fetchUser(rows[0].moderator) ? `<@${rows[0].moderator}>` : rows[0].moderator;
  27.       var reason = rows[0].reason === undefined || !rows[0].reason ? "None" : rows[0].reason;
  28.       var proof = rows[0].proof;
  29.       var embed = new Discord.RichEmbed()
  30.       .setColor("#6700c0")
  31.       .addField("Username:", rows[0].user)
  32.       .addField("Moderator:", moderator)
  33.       .addField("Reason:", reason)
  34.       .addField("Proof:", proof)
  35.       .addField("Ban date:", new Date(rows[0].dateBan).toLocaleDateString("en-US", {
  36.         hourCycle: "h12",
  37.         weekday: "long",
  38.         month: "long",
  39.         day: "numeric",
  40.         year: "numeric",
  41.         hour: "numeric",
  42.         minute: "numeric",
  43.         second: "numeric",
  44.         timeZoneName: "short",
  45.         timeZone: "America/Los_Angeles"
  46.       }))
  47.       .addField("Unban date:", rows[0].perm === 1 ? "Perm ban" : new Date(rows[0].dateUnban).toLocaleDateString("en-US", {
  48.         hourCycle: "h12",
  49.         weekday: "long",
  50.         month: "long",
  51.         day: "numeric",
  52.         year: "numeric",
  53.         hour: "numeric",
  54.         minute: "numeric",
  55.         second: "numeric",
  56.         timeZoneName: "short",
  57.         timeZone: "America/Los_Angeles"
  58.       }));
  59.       message.channel.send(embed);
  60.     } else return message.reply("This user isn't banned, or this user isn't logged.");
  61.   } else if (action === "remove") {
  62.     var user = args[1];
  63.     if (!user) return message.reply("Please include a roblox username.");
  64.     if (user.replace(/[^a-z^0-9^_]/ig, "") !== user) return message.reply("I'm not stupid >;c please include a valid roblox username.");
  65.     var rows = await sql.all(`SELECT * FROM gameBans WHERE LOWER(user) = "${user.toLowerCase()}"`);
  66.     if(!rows[0]) return message.reply("This user isn't banned, or this user isn't logged.")
  67.     sql.run(`DELETE FROM gameBans WHERE LOWER(user) = "${user.toLowerCase()}"`).catch(() => {});
  68.     message.reply("This ban has succesfully been removed from the registry.")
  69.   } else if (action === "list") {
  70.     sql.all("SELECT user FROM gameBans").then(rows => {
  71.       const list = rows.map(obj => obj.user).sort(function(a, b) {
  72.         var A = a.toLowerCase();
  73.         var B = b.toLowerCase();
  74.         if (A > B) return 1;
  75.         if (A < B) return -1;
  76.         if (A === B) return 0;
  77.       });
  78.       const numA = 50 * (Number(args[1]) - 1);
  79.       const numB = 50 + (50 * Number(args[1] - 1));
  80.       if (!args[1]) {
  81.         return message.channel.send(list.slice(0, 49));
  82.       } else if (args[1]) {
  83.         return message.channel.send(list.slice(numA, numB));
  84.       }
  85.     });
  86.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement