feat/40-reroll-on-disinterest #54
@ -225,29 +225,31 @@ export default class VoteController {
|
||||
|
||||
const lastMessage: Message<true> = messages[0]
|
||||
|
||||
logger.debug(`Found messages: ${JSON.stringify(messages, null, 2)}`, { guildId, requestId })
|
||||
|
||||
logger.debug(`Last message: ${JSON.stringify(lastMessage, null, 2)}`, { guildId, requestId })
|
||||
|
||||
|
||||
const votes = (await this.getVotesByEmote(lastMessage, guildId, requestId))
|
||||
.sort((a, b) => b.count - a.count)
|
||||
|
||||
logger.debug(`votes: ${JSON.stringify(votes, null, 2)}`, { guildId, requestId })
|
||||
|
||||
logger.info("Deleting vote message")
|
||||
await lastMessage.delete()
|
||||
const event = await this.getOpenEvent(guild, guild.id, requestId)
|
||||
if (event && votes?.length > 0) {
|
||||
this.updateOpenPollEventWithVoteResults(event, votes, guild, guildId, requestId)
|
||||
this.sendVoteClosedMessage(event, votes[0].movie, guildId, requestId)
|
||||
if (!isVoteMessage(lastMessage)) {
|
||||
logger.error(`Found message that is not a vote message, can't proceed`, { guildId, requestId })
|
||||
logger.debug(`Found messages: ${JSON.stringify(messages, null, 2)}`, { guildId, requestId })
|
||||
magnetotail marked this conversation as resolved
Outdated
|
||||
logger.debug(`Last message: ${JSON.stringify(lastMessage, null, 2)}`, { guildId, requestId })
|
||||
}
|
||||
else {
|
||||
const votes = (await this.getVotesByEmote(lastMessage, guildId, requestId))
|
||||
.sort((a, b) => b.count - a.count)
|
||||
|
||||
logger.debug(`votes: ${JSON.stringify(votes, null, 2)}`, { guildId, requestId })
|
||||
|
||||
logger.info("Deleting vote message")
|
||||
lastMessage.unpin()
|
||||
await lastMessage.delete()
|
||||
const event = await this.getOpenEvent(guild, guild.id, requestId)
|
||||
if (event && votes?.length > 0) {
|
||||
this.updateOpenPollEventWithVoteResults(event, votes, guild, guildId, requestId)
|
||||
this.sendVoteClosedMessage(event, votes[0].movie, guildId, requestId)
|
||||
}
|
||||
}
|
||||
lastMessage.unpin()
|
||||
}
|
||||
/**
|
||||
* gets votes for the movies without the NONE_OF_THAT votes
|
||||
magnetotail marked this conversation as resolved
Outdated
magnetotail
commented
rename to "getOpenVoteEvent", since other events get filtered out rename to "getOpenVoteEvent", since other events get filtered out
kenobi
commented
ca99987a20baeceda27cb5e206bff42a54f31b04
done
magnetotail
commented
renamed to getOpenPollEvent renamed to getOpenPollEvent
kenobi
commented
4e9fe587b0af1b91f049b820023bd0f7e6280517
renamed
|
||||
*/
|
||||
public async getVotesByEmote(message: Message, guildId: string, requestId: string): Promise<Vote[]> {
|
||||
public async getVotesByEmote(message: VoteMessage, guildId: string, requestId: string): Promise<Vote[]> {
|
||||
const votes: Vote[] = []
|
||||
logger.debug(`Number of items in emotes: ${Object.values(Emotes).length}`, { guildId, requestId })
|
||||
for (let i = 0; i < Object.keys(Emotes).length / 2; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user
remove todo
removed
ca99987a20