Compare commits
3 Commits
98d1ca73b5
...
c351e27fdd
Author | SHA1 | Date | |
---|---|---|---|
c351e27fdd | |||
6d3bea169e | |||
3f071c8a4e |
@ -3,13 +3,16 @@ import { Message, MessageReaction, User } from "discord.js";
|
|||||||
import { logger, newRequestId, noGuildId } from "../logger";
|
import { logger, newRequestId, noGuildId } from "../logger";
|
||||||
import { NONE_OF_THAT } from "../constants";
|
import { NONE_OF_THAT } from "../constants";
|
||||||
import { client } from "../..";
|
import { client } from "../..";
|
||||||
|
import { messageIsVoteMessage } from "../helper/messageIdentifiers";
|
||||||
|
|
||||||
|
|
||||||
export const name = 'messageReactionAdd'
|
export const name = 'messageReactionAdd'
|
||||||
|
|
||||||
export async function execute(messageReaction: MessageReaction, user: User) {
|
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')
|
logger.info('Skipping bot reaction')
|
||||||
|
return
|
||||||
|
}
|
||||||
const requestId = newRequestId()
|
const requestId = newRequestId()
|
||||||
const guildId = messageReaction.message.inGuild() ? messageReaction.message.guildId : noGuildId
|
const guildId = messageReaction.message.inGuild() ? messageReaction.message.guildId : noGuildId
|
||||||
const reactedUponMessage: Message = messageReaction.message.partial ? await messageReaction.message.fetch() : messageReaction.message
|
const reactedUponMessage: Message = messageReaction.message.partial ? await messageReaction.message.fetch() : messageReaction.message
|
||||||
@ -23,8 +26,11 @@ export async function execute(messageReaction: MessageReaction, user: User) {
|
|||||||
|
|
||||||
logger.info(`emoji: ${messageReaction.emoji.toString()}`)
|
logger.info(`emoji: ${messageReaction.emoji.toString()}`)
|
||||||
if (messageReaction.emoji.toString() === NONE_OF_THAT) {
|
if (messageReaction.emoji.toString() === NONE_OF_THAT) {
|
||||||
logger.info(`Reaction is NONE_OF_THAT. Handling`, { requestId, guildId })
|
if (messageIsVoteMessage(reactedUponMessage)) {
|
||||||
|
logger.info(`Reaction is NONE_OF_THAT on a vote message. Handling`, { requestId, guildId })
|
||||||
return client.VoteController.handleNoneOfThatVote(messageReaction, user, reactedUponMessage, requestId, guildId)
|
return client.VoteController.handleNoneOfThatVote(messageReaction, user, reactedUponMessage, requestId, guildId)
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -10,9 +10,7 @@ export default class VoteController {
|
|||||||
|
|
||||||
public async handleNoneOfThatVote(messageReaction: MessageReaction, user: User, reactedUponMessage: Message, requestId: string, guildId: string) {
|
public async handleNoneOfThatVote(messageReaction: MessageReaction, user: User, reactedUponMessage: Message, requestId: string, guildId: string) {
|
||||||
if (!messageReaction.message.guild) return 'No guild'
|
if (!messageReaction.message.guild) return 'No guild'
|
||||||
if (messageIsVoteMessage(reactedUponMessage)) {
|
|
||||||
logger.debug(`${reactedUponMessage.id} is vote message`, { requestId, guildId })
|
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)
|
const watcherRoleMember = await getMembersWithRoleFromGuild(config.bot.announcement_role, messageReaction.message.guild)
|
||||||
logger.info("ROLE MEMBERS " + JSON.stringify(watcherRoleMember), { requestId, guildId })
|
logger.info("ROLE MEMBERS " + JSON.stringify(watcherRoleMember), { requestId, guildId })
|
||||||
const watcherRoleMemberCount = watcherRoleMember.size
|
const watcherRoleMemberCount = watcherRoleMember.size
|
||||||
@ -28,6 +26,3 @@ export default class VoteController {
|
|||||||
logger.info(`No reroll`, { requestId, guildId })
|
logger.info(`No reroll`, { requestId, guildId })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user