feat/40-reroll-on-disinterest #54

Merged
kenobi merged 73 commits from feat/40-reroll-on-disinterest into master 2023-11-19 20:24:36 +01:00
3 changed files with 10 additions and 9 deletions
Showing only changes of commit fb4ab59dc6 - Show all commits

View File

@ -1,6 +1,7 @@
export enum Emotes { "1⃣", "2⃣", "3⃣", "4⃣", "5⃣", "6⃣", "7⃣", "8⃣", "9⃣", "🔟" }
export enum ValidVoteEmotes { "1⃣", "2⃣", "3⃣", "4⃣", "5⃣", "6⃣", "7⃣", "8⃣", "9⃣", "🔟" }
export const NONE_OF_THAT = "❌"
magnetotail marked this conversation as resolved
Review

Can this be integrated into Emoji? Maybe provide method to only get number emojis then? By definition "NONE_OF_THAT" is also an emoji

Can this be integrated into Emoji? Maybe provide method to only get number emojis then? By definition "NONE_OF_THAT" is also an emoji
Review

Emotes got renamed to validVoteEmotes

Emotes got renamed to validVoteEmotes
Review

fb4ab59dc6
preliminary solution

fb4ab59dc6de62d8f0fa28fb86e3d18078bf919f preliminary solution
// WIP
export const Emoji = {
"one": "\u0031\uFE0F\u20E3",
"two": "\u0032\uFE0F\u20E3",

View File

@ -1,7 +1,7 @@
kenobi marked this conversation as resolved
Review

Rename file to something like "handleVoteReaction" to make it separate from future reactionadd handlers

Rename file to something like "handleVoteReaction" to make it separate from future reactionadd handlers
Review

Agreement to use handleMessageReactionAdd as a 'reaction pre processor' to hand off reaction emoji to other handling methods and keep the eventHandler itself generic.

Agreement to use handleMessageReactionAdd as a 'reaction pre processor' to hand off reaction emoji to other handling methods and keep the eventHandler itself generic.
import { Message, MessageReaction, User } from "discord.js";
import { logger, newRequestId, noGuildId } from "../logger";
import { Emoji, Emotes, NONE_OF_THAT } from "../constants";
import { Emoji, ValidVoteEmotes, NONE_OF_THAT } from "../constants";
import { client } from "../..";
import { isInitialAnnouncement, isVoteMessage } from "../helper/messageIdentifiers";
@ -26,7 +26,7 @@ export async function execute(messageReaction: MessageReaction, user: User) {
logger.info(`emoji: ${messageReaction.emoji.toString()}`)
if (!Object.values(Emotes).includes(messageReaction.emoji.toString()) && messageReaction.emoji.toString() !== NONE_OF_THAT) {
if (!Object.values(ValidVoteEmotes).includes(messageReaction.emoji.toString()) && messageReaction.emoji.toString() !== NONE_OF_THAT) {
logger.info(`${messageReaction.emoji.toString()} currently not handled`)
return
}

View File

@ -1,5 +1,5 @@
import { Guild, GuildScheduledEvent, GuildScheduledEventEditOptions, GuildScheduledEventSetStatusArg, GuildScheduledEventStatus, Message, MessageCreateOptions, MessageReaction, TextChannel } from "discord.js"
import { Emotes, NONE_OF_THAT } from "../constants"
import { ValidVoteEmotes, NONE_OF_THAT } from "../constants"
import { logger, newRequestId } from "../logger"
import { getMembersWithRoleFromGuild } from "./roleFilter"
import { config } from "../configuration"
@ -187,7 +187,7 @@ export default class VoteController {
let message = `[Abstimmung] für https://discord.com/events/${guildId}/${event.id} \n<@&${config.bot.announcement_role}> Es gibt eine neue Abstimmung für die nächste Watchparty ${createDateStringFromEvent(event.scheduledStartAt, guildId, requestId)}! Stimme hierunter für den nächsten Film ab!\n`
for (let i = 0; i < movies.length; i++) {
message = message.concat(Emotes[i]).concat(": ").concat(movies[i]).concat("\n")
message = message.concat(ValidVoteEmotes[i]).concat(": ").concat(movies[i]).concat("\n")
}
message = message.concat(NONE_OF_THAT).concat(": Wenn dir nichts davon gefällt.")
@ -205,7 +205,7 @@ export default class VoteController {
const sentMessage: Message<true> = await (await announcementChannel.fetch()).send(options)
for (let i = 0; i < movieCount; i++) {
sentMessage.react(Emotes[i])
sentMessage.react(ValidVoteEmotes[i])
}
sentMessage.react(NONE_OF_THAT)
@ -260,9 +260,9 @@ export default class VoteController {
*/
public async getVotesByEmote(message: VoteMessage, guildId: string, requestId: string): Promise<Vote[]> {
const votes: Vote[] = []
magnetotail marked this conversation as resolved
Review

should be renamed so it's clear what the event gets updated with and what it looks like in the end and what kind of event gets updated (I guess open poll events)

should be renamed so it's clear what the event gets updated with and what it looks like in the end and what kind of event gets updated (I guess open poll events)
Review

ca99987a
done

ca99987a done
logger.debug(`Number of items in emotes: ${Object.values(Emotes).length}`, { guildId, requestId })
for (let i = 0; i < Object.keys(Emotes).length / 2; i++) {
const emote = Emotes[i]
logger.debug(`Number of items in emotes: ${Object.values(ValidVoteEmotes).length}`, { guildId, requestId })
for (let i = 0; i < Object.keys(ValidVoteEmotes).length / 2; i++) {
const emote = ValidVoteEmotes[i]
logger.debug(`Getting reaction for emote ${emote}`, { guildId, requestId })
const reaction = message.reactions.resolve(emote)
logger.debug(`Reaction for emote ${emote}: ${JSON.stringify(reaction, null, 2)}`, { guildId, requestId })