mrhankypower
This commit is contained in:
parent
3ce187279b
commit
343e915749
|
@ -5,7 +5,7 @@ module.exports = (lib) => {
|
||||||
level: 0,
|
level: 0,
|
||||||
active: 1,
|
active: 1,
|
||||||
func: (e) => {
|
func: (e) => {
|
||||||
let args = lib.sql.escape(e.message).split(" ").slice(2);
|
let args = lib.sql.escape(e.message).trim().split(" ").slice(2);
|
||||||
let params = {
|
let params = {
|
||||||
"in": [],
|
"in": [],
|
||||||
"not": []
|
"not": []
|
||||||
|
@ -19,23 +19,16 @@ module.exports = (lib) => {
|
||||||
params.in.push(name);
|
params.in.push(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
let query = "select `id`,`username` from `f0ck`.`items` ";
|
let vars = params.in.concat(exc);
|
||||||
|
|
||||||
if(args.length > 0)
|
params.in = new Array(params.in.length).fill('username LIKE ?');
|
||||||
query += "where ";
|
params.out = params.in.length > 0 ? [] : new Array(params.out.length).fill('username NOT LIKE ?');
|
||||||
if(params.in.length > 0)
|
let where = params.in.concat(params.out);
|
||||||
query += "`username` like '" + params.in.join("' || `username` like '");
|
let query = `SELECT id, username FROM f0ck.items ${where.length > 0 ? `WHERE ${where.join(' || ')}` : ''} ORDER BY rand() LIMIT 1`;
|
||||||
if(params.not.length > 0)
|
|
||||||
query += "`username` not like '" + params.not.join("' || `username` not like '");
|
|
||||||
|
|
||||||
query += " order by rand() limit 1";
|
|
||||||
|
|
||||||
console.log( query );
|
console.log( query );
|
||||||
lib.sql.query(query, (err, rows, fields) => {
|
lib.sql.query(query, vars, (err, rows) => {
|
||||||
if(!err && rows.length > 0)
|
e.reply(!err && rows.length > 0 ? `f0ckrnd: ${lib.cfg.main.url}/${rows[0].id} by: ${rows[0].username}` : 'nothing found, f0cker');
|
||||||
e.reply(`f0ckrnd: ${lib.cfg.main.url}/${rows[0].id} by: ${rows[0].username}`);
|
|
||||||
else
|
|
||||||
e.reply("nothing found, f0cker");
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
desc: 'Random-f0ck'
|
desc: 'Random-f0ck'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user