This repository was archived by the owner on Oct 9, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ model userData {
159159 // username is only guarenteed to be set and/or used for blacklisted users
160160 username String ?
161161 locale String ?
162- lastVoted Int ?
162+ lastVoted DateTime ?
163163 voteCount Int @default (0 )
164164 blacklistedFrom hubBlacklist []
165165 // if user has seen the welcome message when they first use the network
Original file line number Diff line number Diff line change @@ -22,9 +22,7 @@ export class VoteManager extends EventEmitter {
2222 this . cluster = cluster ;
2323 this . scheduler = scheduler ;
2424 this . scheduler . addRecurringTask ( 'removeVoterRole' , 60 * 60 * 1_000 , async ( ) => {
25- const expiredVotes = await db . userData . findMany ( {
26- where : { lastVoted : { lt : new Date ( ) . getTime ( ) } } ,
27- } ) ;
25+ const expiredVotes = await db . userData . findMany ( { where : { lastVoted : { lt : new Date ( ) } } } ) ;
2826 for ( const vote of expiredVotes ) {
2927 this . emit ( 'voteExpired' , vote . userId ) ;
3028 await this . removeVoterRole ( vote . userId ) ;
@@ -50,7 +48,7 @@ export class VoteManager extends EventEmitter {
5048 }
5149
5250 async incrementUserVote ( userId : string , username ?: string ) {
53- const lastVoted = new Date ( ) . getTime ( ) ;
51+ const lastVoted = new Date ( ) ;
5452 return await db . userData . upsert ( {
5553 where : { userId } ,
5654 create : {
@@ -88,7 +86,7 @@ export class VoteManager extends EventEmitter {
8886 ` ,
8987 )
9088 . setFooter ( { text : `This is your ${ voteCount } ${ ordinalSuffix } time voting!` } )
91- . setColor ( 'Orange ' ) ,
89+ . setColor ( 'Green ' ) ,
9290 ] ,
9391 } ) ;
9492 }
Original file line number Diff line number Diff line change @@ -87,10 +87,14 @@ export const hasVoted = async (userId: Snowflake): Promise<boolean> => {
8787} ;
8888
8989export const userVotedToday = async ( userId : Snowflake ) : Promise < boolean > => {
90- const res = await db . userData . findFirst ( { where : { userId } } ) ;
90+ const res = await db . userData . findFirst ( {
91+ where : {
92+ userId,
93+ lastVoted : { gte : new Date ( Date . now ( ) - 60 * 60 * 24 * 1000 ) } ,
94+ } ,
95+ } ) ;
9196
92- const oneDay = Date . now ( ) - 60 * 60 * 24 * 1000 ;
93- return ( res ?. lastVoted && res . lastVoted > oneDay ) === true ;
97+ return Boolean ( res ?. lastVoted ) ;
9498} ;
9599
96100export const yesOrNoEmoji = ( option : unknown , yesEmoji : string , noEmoji : string ) => {
You can’t perform that action at this time.
0 commit comments