random(?)
This commit is contained in:
		@@ -10,6 +10,7 @@ export default async bot => {
 | 
			
		||||
    active: false,
 | 
			
		||||
    f: async e => {
 | 
			
		||||
      let args = e.args.slice(1);
 | 
			
		||||
 | 
			
		||||
      /*let rows = sql("items").select("id", "username", "mime", "size");
 | 
			
		||||
 | 
			
		||||
      for(let i = 0; i < args.length; i++) {
 | 
			
		||||
@@ -21,6 +22,26 @@ export default async bot => {
 | 
			
		||||
 | 
			
		||||
      rows = await rows.orderByRaw("random()").limit(1);*/
 | 
			
		||||
 | 
			
		||||
      const rows = await db`
 | 
			
		||||
        select id, mime, username, size
 | 
			
		||||
        from "items"
 | 
			
		||||
        where
 | 
			
		||||
        ${ args.map(a => a.charAt(0) === "!"
 | 
			
		||||
          ? db`username not ilike ${a.slice(1)}`
 | 
			
		||||
          : db`username ilike ${a}`
 | 
			
		||||
        ).join(' and ')}
 | 
			
		||||
        order by random()
 | 
			
		||||
      `;
 | 
			
		||||
 | 
			
		||||
      console.log(`select id, mime, username, size
 | 
			
		||||
      from "items"
 | 
			
		||||
      where
 | 
			
		||||
      ${ args.map(a => a.charAt(0) === "!"
 | 
			
		||||
        ? `username not ilike ${a.slice(1)}`
 | 
			
		||||
        : `username ilike ${a}`
 | 
			
		||||
      ).join(' and ')}
 | 
			
		||||
      order by random()`);
 | 
			
		||||
 | 
			
		||||
      if(rows.length === 0)
 | 
			
		||||
        return e.reply("nothing found, f0cker");
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user