Compare commits
3 Commits
0d3c62c6ad
...
b8a32aab40
Author | SHA1 | Date | |
---|---|---|---|
b8a32aab40 | |||
e3e755011d | |||
5a6c66cb3e |
20
server/events/handleReactionAdd.ts
Normal file
20
server/events/handleReactionAdd.ts
Normal 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
|
||||
}
|
6
server/helper/messageIdentifiers.ts
Normal file
6
server/helper/messageIdentifiers.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { Message } from "discord.js";
|
||||
|
||||
export function messageIsVoteMessage(msg: Message): boolean {
|
||||
return msg.content.includes('[Abstimmung]')
|
||||
|
||||
}
|
@ -1,5 +1,8 @@
|
||||
import { createLogger, format, transports } from "winston"
|
||||
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 }) => {
|
||||
|
Loading…
Reference in New Issue
Block a user