From e9471f85dfda05f73923ab4c757506bc4de10d85 Mon Sep 17 00:00:00 2001 From: Flummi Date: Wed, 22 Mar 2017 00:10:26 +0100 Subject: [PATCH] test xD --- src/trigger/f0ckrand.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/trigger/f0ckrand.js b/src/trigger/f0ckrand.js index d8ca230..5ab45f7 100644 --- a/src/trigger/f0ckrand.js +++ b/src/trigger/f0ckrand.js @@ -1,11 +1,21 @@ module.exports = (lib) => { lib.trigger.add({ name: 'f0ckrand', - call: /^gib f0ck$/i, + call: /^gib f0ck/i, level: 0, active: 1, func: (e) => { - lib.sql.query("select `id`,`username` from `f0ck`.`items` order by rand() limit 1", (err, rows, fields) => { + let args = e.message.split(" "); + args.shift().shift(); + + let query = "select `id`,`username` from `f0ck`.`items` order by rand() "; + + if(args.length > 0) { + query += "where `username` = ? ".repeat(args.length); + } + + query += "limit 1"; + lib.sql.query(query, args, (err, rows, fields) => { if(!err) e.reply("f0ckrnd: "+lib.cfg.main.url+"/"+rows[0].id+" by: "+rows[0].username); });