mirror of
https://github.com/koreanbots/core.git
synced 2025-12-15 22:10:24 +00:00
fix: vote api not working properly
This commit is contained in:
parent
160fe4ecb3
commit
b90fa8f11e
@ -507,10 +507,15 @@ async function getVote(
|
|||||||
targetID: string,
|
targetID: string,
|
||||||
type: 'bot' | 'server'
|
type: 'bot' | 'server'
|
||||||
): Promise<number | null> {
|
): Promise<number | null> {
|
||||||
const user = await knex('users').select(['votes']).where({ id: userID })
|
const [vote] = await knex('votes')
|
||||||
if (user.length === 0) return null
|
.select('last_voted')
|
||||||
const data = JSON.parse(user[0].votes)
|
.where({
|
||||||
return data[`${type}:${targetID}`] || 0
|
user_id: userID,
|
||||||
|
target: targetID,
|
||||||
|
type: type === 'bot' ? ObjectType.Bot : ObjectType.Server,
|
||||||
|
})
|
||||||
|
if (!vote) return null
|
||||||
|
return vote.last_voted.getTime() || 0
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getWebhook(id: string, type: 'bots' | 'servers'): Promise<Webhook | null> {
|
async function getWebhook(id: string, type: 'bots' | 'servers'): Promise<Webhook | null> {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user