Compare commits

...

3 Commits

Author SHA1 Message Date
b8a32aab40 stub for reactionhandling
All checks were successful
Compile the repository / compile (pull_request) Successful in 1m14s
Run unit tests / test (pull_request) Successful in 1m38s
2023-06-25 01:57:40 +02:00
e3e755011d add messageIdentifier helper 2023-06-25 01:57:30 +02:00
5a6c66cb3e export newRequestId from logger 2023-06-25 01:57:14 +02:00
3 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,20 @@
import { Message, MessageReaction, User } from "discord.js";
import { messageIsVoteMessage } from "../helper/messageIdentifiers";
import { logger, newRequestId, noGuildId } from "../logger";
export const name = 'messageReactionAdd'
export async function execute(messageReaction: MessageReaction, user: User) {
const requestId = newRequestId
const guildId = messageReaction.message.inGuild() ? messageReaction.message.guildId : noGuildId
const reactedUponMessage: Message = messageReaction.message.partial ? await messageReaction.message.fetch() : messageReaction.message
if (messageIsVoteMessage(reactedUponMessage)) {
logger.info(`Got reaction on message`, { requestId, guildId })
}
return
}

View File

@ -0,0 +1,6 @@
import { Message } from "discord.js";
export function messageIsVoteMessage(msg: Message): boolean {
return msg.content.includes('[Abstimmung]')
}

View File

@ -1,5 +1,8 @@
import { createLogger, format, transports } from "winston" import { createLogger, format, transports } from "winston"
import { config } from "./configuration" import { config } from "./configuration"
import { v4 } from "uuid"
export const newRequestId = v4()
export const noGuildId = 'NoGuildId'
const printFn = format.printf(({ guildId, level, message, errorCode, requestId, timestamp: logTimestamp }: { [k: string]: string }) => { const printFn = format.printf(({ guildId, level, message, errorCode, requestId, timestamp: logTimestamp }: { [k: string]: string }) => {