removed entry can't win giveaway

This commit is contained in:
kingomes
2024-11-02 22:37:45 -05:00
parent 41323c49ae
commit ba9c8c8118
3 changed files with 24 additions and 5 deletions

View File

@@ -144,6 +144,8 @@ export default commandModule({
)
embedMessage.edit({embeds: [embed]})
embedMessage.reply(`Congratulations <@${winnerId}> on winning the ${item} giveaway!`)
}
else if (stmt.length > 1 && stmt[winnerIndex].user_id === ctx.userId) {
winnerIndex = Math.floor(Math.random() * stmt.length)
@@ -164,4 +166,4 @@ export default commandModule({
db.prepare(`DELETE FROM entrees`).run()
}
})
})

View File

@@ -6,10 +6,12 @@ export default discordEvent({
execute: async (reaction, potentialWinners) => {
const startTime = reaction.message.createdTimestamp
const stmt = db.prepare(`INSERT INTO entrees(timestamp, user_id) VALUES (?, ?)`)
if (reaction.emoji.name === '🎉') {
const stmt = db.prepare(`INSERT INTO entrees(timestamp, user_id) VALUES (?, ?)`)
if (potentialWinners.bot === false) {
stmt.run([startTime, potentialWinners.id])
if (potentialWinners.bot === false) {
stmt.run([startTime, potentialWinners.id])
}
}
}
})
})

View File

@@ -0,0 +1,15 @@
import { discordEvent } from "@sern/handler";
import { db } from "../utils/db.js"
export default discordEvent({
name: 'messageReactionRemove',
execute: async (reaction, deletedEntry) => {
const deletedId = deletedEntry.id
if (reaction.emoji.name === '🎉') {
const stmt = db.prepare(`DELETE FROM entrees WHERE user_id = ?`)
stmt.run(deletedId)
}
}
})