add messageReactionRemove
This commit is contained in:
parent
2c8cd96ac7
commit
016bb243cc
33
server/events/handleMessageReactionRemove.ts
Normal file
33
server/events/handleMessageReactionRemove.ts
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
import { Message, MessageReaction, User } from "discord.js";
|
||||
import { logger, newRequestId, noGuildId } from "../logger";
|
||||
import { Emoji } from "../constants";
|
||||
import { client } from "../..";
|
||||
import { isInitialAnnouncement } from "../helper/messageIdentifiers";
|
||||
|
||||
|
||||
export const name = 'messageReactionRemove'
|
||||
|
||||
export async function execute(messageReaction: MessageReaction, user: User) {
|
||||
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
|
||||
if (!messageReaction.message.guild) {
|
||||
logger.warn(`Received messageReactionRemove on non-guild message.`, { requestId })
|
||||
return
|
||||
}
|
||||
|
||||
logger.info(`Got reaction on message`, { requestId, guildId })
|
||||
|
||||
logger.info(`emoji: ${messageReaction.emoji.toString()}`)
|
||||
if (isInitialAnnouncement(reactedUponMessage)) {
|
||||
if (messageReaction.emoji.toString() === Emoji.ticket) {
|
||||
logger.info(`User: ${user.id}, ${user.username} has removed a ticket reaction. Starting role management`, { requestId, guildId })
|
||||
return client.roleController.removeMediaRoleFromUser(user, guildId, requestId)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user