Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (action === "add") {
- var user = args[1];
- if (!user) return message.reply("Please include a roblox username.");
- if (user.replace(/[^a-z^0-9^_]/ig, "") !== user) return message.reply("I'm not stupid >;c please include a valid roblox username.");
- var rows = await sql.all(`SELECT * FROM gameBans WHERE LOWER(user) = "${user.toLowerCase()}"`);
- if(!rows[0]) {
- var reason = message.content.toLowerCase().includes("proof:") ? args.slice(2, args.findIndex(i => i.toLowerCase() === "proof:")).join(" ") : args.slice(2).join(" ");
- if(!reason) return message.reply("Please include a reason.");
- var int = args.findIndex(i => i.toLowerCase() === "proof:") + 1;
- 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(" ");
- if(!proof) return message.reply("Please include proof.");
- 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.");
- if(message.content.toLowerCase().includes("duration:")) {
- } else {
- 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]);
- message.reply("This ban has succesfully been logged into the registry.");
- }
- } else return message.reply("This user is already banned, doofus.");
- } else if (action === "check") {
- var user = args[1];
- if (!user) return message.reply("Please include a roblox username.");
- if (user.replace(/[^a-z^0-9^_]/ig, "") !== user) return message.reply("I'm not stupid >;c please include a valid roblox username.");
- var rows = await sql.all(`SELECT * FROM gameBans WHERE LOWER(user) = "${user.toLowerCase()}"`);
- if(rows[0]) {
- var moderator = await client.fetchUser(rows[0].moderator) ? `<@${rows[0].moderator}>` : rows[0].moderator;
- var reason = rows[0].reason === undefined || !rows[0].reason ? "None" : rows[0].reason;
- var proof = rows[0].proof;
- var embed = new Discord.RichEmbed()
- .setColor("#6700c0")
- .addField("Username:", rows[0].user)
- .addField("Moderator:", moderator)
- .addField("Reason:", reason)
- .addField("Proof:", proof)
- .addField("Ban date:", new Date(rows[0].dateBan).toLocaleDateString("en-US", {
- hourCycle: "h12",
- weekday: "long",
- month: "long",
- day: "numeric",
- year: "numeric",
- hour: "numeric",
- minute: "numeric",
- second: "numeric",
- timeZoneName: "short",
- timeZone: "America/Los_Angeles"
- }))
- .addField("Unban date:", rows[0].perm === 1 ? "Perm ban" : new Date(rows[0].dateUnban).toLocaleDateString("en-US", {
- hourCycle: "h12",
- weekday: "long",
- month: "long",
- day: "numeric",
- year: "numeric",
- hour: "numeric",
- minute: "numeric",
- second: "numeric",
- timeZoneName: "short",
- timeZone: "America/Los_Angeles"
- }));
- message.channel.send(embed);
- } else return message.reply("This user isn't banned, or this user isn't logged.");
- } else if (action === "remove") {
- var user = args[1];
- if (!user) return message.reply("Please include a roblox username.");
- if (user.replace(/[^a-z^0-9^_]/ig, "") !== user) return message.reply("I'm not stupid >;c please include a valid roblox username.");
- var rows = await sql.all(`SELECT * FROM gameBans WHERE LOWER(user) = "${user.toLowerCase()}"`);
- if(!rows[0]) return message.reply("This user isn't banned, or this user isn't logged.")
- sql.run(`DELETE FROM gameBans WHERE LOWER(user) = "${user.toLowerCase()}"`).catch(() => {});
- message.reply("This ban has succesfully been removed from the registry.")
- } else if (action === "list") {
- sql.all("SELECT user FROM gameBans").then(rows => {
- const list = rows.map(obj => obj.user).sort(function(a, b) {
- var A = a.toLowerCase();
- var B = b.toLowerCase();
- if (A > B) return 1;
- if (A < B) return -1;
- if (A === B) return 0;
- });
- const numA = 50 * (Number(args[1]) - 1);
- const numB = 50 + (50 * Number(args[1] - 1));
- if (!args[1]) {
- return message.channel.send(list.slice(0, 49));
- } else if (args[1]) {
- return message.channel.send(list.slice(numA, numB));
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement