This commit is contained in:
Flummi
2020-10-13 10:59:06 +02:00
parent 22527d2552
commit a01f19c644
4 changed files with 18 additions and 15 deletions

View File

@ -23,11 +23,11 @@ export default async bot => {
params.inc.push(name);
}
let vars = params.inc.concat(params.inc.length == 0 ? params.exc : []);
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 where = params.inc.concat(params.exc).join(" || ");
const 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)