Skip to content

Commit

Permalink
chore: track all related functions
Browse files Browse the repository at this point in the history
  • Loading branch information
skinmaker1345 committed Mar 5, 2024
1 parent 3a8b5de commit 4010578
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion utils/Query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { markdownImage } from './Regex'
export const imageRateLimit = new TLRU<unknown, number>({ maxAgeMs: 60000 })

async function getBot(id: string, topLevel = true): Promise<Bot> {
console.log('getBot, id:', id)
const res = await knex('bots')
.select([
'id',
Expand Down Expand Up @@ -72,7 +73,9 @@ async function getBot(id: string, topLevel = true): Promise<Bot> {
.orWhere({ vanity: id, partnered: true })
if (res[0]) {
const discordBot = await get.discord.user.load(res[0].id)
if (!discordBot) return null
if (!discordBot) {
console.log(`discordBot for id ${res[0].id} is`, discordBot, 'returning null')
}
const botMember = (await getMainGuild()
?.members?.fetch(res[0].id)
.catch((e) => {
Expand Down Expand Up @@ -193,6 +196,7 @@ async function getServerData(id: string): Promise<ServerData | null> {
}

async function getUser(id: string, topLevel = true): Promise<User> {
console.log('getUser', id, topLevel)
const res = await knex('users').select(['id', 'flags', 'github']).where({ id })
if (res[0]) {
const ownedBots = await knex('bots')
Expand Down Expand Up @@ -236,6 +240,7 @@ async function getUserGuilds(id: string): Promise<Nullable<RawGuild[]>> {
}

async function getBotList(type: ListType, page = 1, query?: string): Promise<List<Bot>> {
console.log('getBotList', type, page, query)
let res: { id: string }[]
let count: string | number
if (type === 'VOTE') {
Expand Down Expand Up @@ -267,6 +272,7 @@ async function getBotList(type: ListType, page = 1, query?: string): Promise<Lis
.offset(((page ? Number(page) : 1) - 1) * 16)
.select(['id'])
.whereNot({ state: 'blocked' })
console.log('new, res:', res)
} else if (type === 'PARTNERED') {
count = (
await knex('bots').where({ partnered: true }).andWhereNot({ state: 'blocked' }).count()
Expand Down Expand Up @@ -795,6 +801,7 @@ async function getImage(url: string) {
}

async function getDiscordUser(id: string): Promise<DiscordUser> {
console.log('getDiscordUser', id)
return await DiscordBot.users
.fetch(id)
.then((u) => u)
Expand Down

0 comments on commit 4010578

Please sign in to comment.