mirror of
https://github.com/koreanbots/core.git
synced 2025-12-18 07:00:23 +00:00
feat(Query): added management queries
This commit is contained in:
parent
3b01067277
commit
4f821bfc37
@ -3,7 +3,7 @@ import { TLRU } from 'tlru'
|
|||||||
import DataLoader from 'dataloader'
|
import DataLoader from 'dataloader'
|
||||||
import { User as DiscordUser } from 'discord.js'
|
import { User as DiscordUser } from 'discord.js'
|
||||||
|
|
||||||
import { Bot, User, ListType, BotList, TokenRegister, BotFlags, DiscordUserFlags, SubmittedBot } from '@types'
|
import { Bot, User, ListType, BotList, TokenRegister, BotFlags, DiscordUserFlags, SubmittedBot, UserSpec } from '@types'
|
||||||
import { categories, imageSafeHost, SpecialEndPoints, VOTE_COOLDOWN } from './Constants'
|
import { categories, imageSafeHost, SpecialEndPoints, VOTE_COOLDOWN } from './Constants'
|
||||||
|
|
||||||
import knex from './Knex'
|
import knex from './Knex'
|
||||||
@ -512,6 +512,19 @@ export const remove = {
|
|||||||
bot: deleteBot
|
bot: deleteBot
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const management = {
|
||||||
|
user: {
|
||||||
|
get: async (id: string): Promise<UserSpec> => {
|
||||||
|
const user = await get.user.load(id)
|
||||||
|
const userSpec = await knex('users').select(['email', 'perm']).where({ id })
|
||||||
|
return user && userSpec[0] ? { ...user, ...userSpec[0] } : null
|
||||||
|
},
|
||||||
|
update: async (id: string, { flags }:{ flags: number }) => {
|
||||||
|
await knex('users').update({ flags }).where({ id })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const ratelimit = {
|
export const ratelimit = {
|
||||||
image: (ip: string) => {
|
image: (ip: string) => {
|
||||||
addRequest(ip, imageRateLimit)
|
addRequest(ip, imageRateLimit)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user