reorder close poll and use message identifier
This commit is contained in:
parent
68546b0b50
commit
976175242b
@ -225,29 +225,31 @@ export default class VoteController {
|
|||||||
|
|
||||||
const lastMessage: Message<true> = messages[0]
|
const lastMessage: Message<true> = messages[0]
|
||||||
|
|
||||||
logger.debug(`Found messages: ${JSON.stringify(messages, null, 2)}`, { guildId, requestId })
|
if (!isVoteMessage(lastMessage)) {
|
||||||
|
logger.error(`Found message that is not a vote message, can't proceed`, { guildId, requestId })
|
||||||
logger.debug(`Last message: ${JSON.stringify(lastMessage, null, 2)}`, { guildId, requestId })
|
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))
|
else {
|
||||||
.sort((a, b) => b.count - a.count)
|
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.debug(`votes: ${JSON.stringify(votes, null, 2)}`, { guildId, requestId })
|
||||||
logger.info("Deleting vote message")
|
|
||||||
await lastMessage.delete()
|
logger.info("Deleting vote message")
|
||||||
const event = await this.getOpenEvent(guild, guild.id, requestId)
|
lastMessage.unpin()
|
||||||
if (event && votes?.length > 0) {
|
await lastMessage.delete()
|
||||||
this.updateOpenPollEventWithVoteResults(event, votes, guild, guildId, requestId)
|
const event = await this.getOpenEvent(guild, guild.id, requestId)
|
||||||
this.sendVoteClosedMessage(event, votes[0].movie, guildId, 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
|
* gets votes for the movies without the NONE_OF_THAT votes
|
||||||
*/
|
*/
|
||||||
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[] = []
|
const votes: Vote[] = []
|
||||||
logger.debug(`Number of items in emotes: ${Object.values(Emotes).length}`, { guildId, requestId })
|
logger.debug(`Number of items in emotes: ${Object.values(Emotes).length}`, { guildId, requestId })
|
||||||
for (let i = 0; i < Object.keys(Emotes).length / 2; i++) {
|
for (let i = 0; i < Object.keys(Emotes).length / 2; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user