Compare commits

..

No commits in common. "c351e27fdd423420cc59fb4e10abaf0f617b2736" and "98d1ca73b5ae0eb5f8682922dad481749cdae467" have entirely different histories.

2 changed files with 20 additions and 21 deletions

View File

@ -3,16 +3,13 @@ import { Message, MessageReaction, User } from "discord.js";
import { logger, newRequestId, noGuildId } from "../logger";
import { NONE_OF_THAT } from "../constants";
import { client } from "../..";
import { messageIsVoteMessage } from "../helper/messageIdentifiers";
export const name = 'messageReactionAdd'
export async function execute(messageReaction: MessageReaction, user: User) {
if (user.id == client.user?.id) {
if (user.id == client.user?.id)
logger.info('Skipping bot reaction')
return
}
const requestId = newRequestId()
const guildId = messageReaction.message.inGuild() ? messageReaction.message.guildId : noGuildId
const reactedUponMessage: Message = messageReaction.message.partial ? await messageReaction.message.fetch() : messageReaction.message
@ -26,11 +23,8 @@ export async function execute(messageReaction: MessageReaction, user: User) {
logger.info(`emoji: ${messageReaction.emoji.toString()}`)
if (messageReaction.emoji.toString() === NONE_OF_THAT) {
if (messageIsVoteMessage(reactedUponMessage)) {
logger.info(`Reaction is NONE_OF_THAT on a vote message. Handling`, { requestId, guildId })
logger.info(`Reaction is NONE_OF_THAT. Handling`, { requestId, guildId })
return client.VoteController.handleNoneOfThatVote(messageReaction, user, reactedUponMessage, requestId, guildId)
}
}
return

View File

@ -10,7 +10,9 @@ export default class VoteController {
public async handleNoneOfThatVote(messageReaction: MessageReaction, user: User, reactedUponMessage: Message, requestId: string, guildId: string) {
if (!messageReaction.message.guild) return 'No guild'
if (messageIsVoteMessage(reactedUponMessage)) {
logger.debug(`${reactedUponMessage.id} is vote message`, { requestId, guildId })
if (messageReaction.message.reactions.cache.find(reaction => reaction.emoji.toString() == NONE_OF_THAT)) {
const watcherRoleMember = await getMembersWithRoleFromGuild(config.bot.announcement_role, messageReaction.message.guild)
logger.info("ROLE MEMBERS " + JSON.stringify(watcherRoleMember), { requestId, guildId })
const watcherRoleMemberCount = watcherRoleMember.size
@ -25,4 +27,7 @@ export default class VoteController {
}
logger.info(`No reroll`, { requestId, guildId })
}
}
}
}