This commit is contained in:
Flummi
2020-04-03 13:12:35 +02:00
parent d39deeb038
commit a202ae2e69
11 changed files with 297 additions and 16 deletions

View File

@ -0,0 +1,39 @@
import sql from "../sql.mjs";
import lib from "../lib.mjs";
import cfg from "../../../config.json";
export default async bot => {
return [{
name: "f0ckrand",
call: /^gib f0ck/i,
active: true,
f: async e => {
let args = e.args.slice(2);
let params = {
inc: [],
exc: []
};
for(let i = 0; i < args.length; i++) {
let name = args[0];
if(name.charAt(0) === "!")
params.exc.push(name.slice(1));
else
params.inc.push(name);
}
let vars = params.inc.concat(params.inc.length == 0 ? params.exc : []);
params.inc = new Array(params.inc.length).fill("username like ?");
params.exc = new Array(params.inc.length == 0 ? params.exc.length : 0).fill("username not like ?");
let where = params.inc.concat(params.exc).join(" || ");
let query = `select id, username, mime, size from items ${where.length > 0 ? `where ${where}` : ""} order by rand() limit 1`;
const rows = await sql.query(query, vars);
if(rows.length === 0)
return e.reply("nothing found, f0cker");
e.reply(`f0ckrnd: ${cfg.main.url}/${rows[0].id} by: ${rows[0].username} (${rows[0].mime}, ~${lib.formatSize(rows[0].size)})`);
}
}];
};