From 5a28ac284cc5e266f08fea9117b7fe0a40094878 Mon Sep 17 00:00:00 2001 From: SKINMAKER Date: Mon, 16 Jan 2023 13:07:01 +0900 Subject: [PATCH] fix: sort bots with date (#530) --- utils/Query.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/utils/Query.ts b/utils/Query.ts index b934881..3dee3f8 100644 --- a/utils/Query.ts +++ b/utils/Query.ts @@ -147,16 +147,18 @@ async function getUser(id: string, topLevel = true):Promise { const ownedBots = await knex('bots') .select(['id']) .where('owners', 'like', `%${id}%`) + .orderBy('date', 'asc') const ownedServer = await knex('servers') .select(['id']) .where('owners', 'like', `%${id}%`) + .orderBy('date', 'asc') const discordUser = await get.discord.user.load(id) res[0].tag = discordUser?.discriminator || '0000' res[0].username = discordUser?.username || 'Unknown User' if (topLevel) { - res[0].bots = (await Promise.all(ownedBots.map(async b => await get._rawBot.load(b.id)))).filter((el: Bot | null) => el).map(row => ({ ...row })) - res[0].servers = (await Promise.all(ownedServer.map(async b => await get._rawServer.load(b.id)))).filter((el: Server | null) => el).map(row => ({ ...row })) + res[0].bots = (await Promise.all(ownedBots.map(async b => await get._rawBot.load(b.id)))).filter((el: Bot | null) => el) + res[0].servers = (await Promise.all(ownedServer.map(async b => await get._rawServer.load(b.id)))).filter((el: Server | null) => el) } else { res[0].bots = ownedBots.map(el => el.id)