Compare commits
4 Commits
fec0bc31f1
...
016bb243cc
Author | SHA1 | Date | |
---|---|---|---|
016bb243cc | |||
2c8cd96ac7 | |||
ba4aefed8e | |||
8efae12907 |
@ -22,7 +22,6 @@ export async function execute(messageReaction: MessageReaction, user: User) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`Got reaction on message`, { requestId, guildId })
|
logger.info(`Got reaction on message`, { requestId, guildId })
|
||||||
//logger.debug(`reactedUponMessage payload: ${JSON.stringify(reactedUponMessage)}`)
|
|
||||||
|
|
||||||
logger.info(`emoji: ${messageReaction.emoji.toString()}`)
|
logger.info(`emoji: ${messageReaction.emoji.toString()}`)
|
||||||
|
|
||||||
@ -39,7 +38,8 @@ export async function execute(messageReaction: MessageReaction, user: User) {
|
|||||||
}
|
}
|
||||||
else if (isInitialAnnouncement(reactedUponMessage)) {
|
else if (isInitialAnnouncement(reactedUponMessage)) {
|
||||||
if (messageReaction.emoji.toString() === Emoji.ticket) {
|
if (messageReaction.emoji.toString() === Emoji.ticket) {
|
||||||
logger.error(`Got a role emoji. Not implemented yet. ${reactedUponMessage.id}`)
|
logger.error(`Got a role emoji. ${reactedUponMessage.id}`)
|
||||||
|
return client.roleController.addMediaRoleToUser(user, guildId, requestId)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
25
server/helper/role.controller.ts
Normal file
25
server/helper/role.controller.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { Role, User } from "discord.js";
|
||||||
|
import { ExtendedClient } from "../structures/client";
|
||||||
|
|
||||||
|
export default class RoleController {
|
||||||
|
|
||||||
|
constructor(private client: ExtendedClient) { }
|
||||||
|
private getMediaRoleForGuild(guildId: string): Role {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
public addRoleToUser(user: User, role: Role, guildId: string, requestId: string) {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
private removeRoleFromUser(user: User, roleToAdd: any, guildId: string, requestId: string) {
|
||||||
|
throw new Error("Method not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public addMediaRoleToUser(user: User, guildId: string, requestId: string) {
|
||||||
|
const roleToAdd: Role = this.getMediaRoleForGuild(guildId)
|
||||||
|
return this.addRoleToUser(user, roleToAdd, guildId, requestId)
|
||||||
|
}
|
||||||
|
public removeMediaRoleFromUser(user: User, guildId: string, requestId: string) {
|
||||||
|
const roleToRemove: Role = this.getMediaRoleForGuild(guildId)
|
||||||
|
return this.removeRoleFromUser(user, roleToRemove, guildId, requestId)
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,7 @@ import { CommandType } from "../types/commandTypes";
|
|||||||
import { isInitialAnnouncement } from "../helper/messageIdentifiers";
|
import { isInitialAnnouncement } from "../helper/messageIdentifiers";
|
||||||
import VoteController from "../helper/vote.controller";
|
import VoteController from "../helper/vote.controller";
|
||||||
import { yavinJellyfinHandler } from "../..";
|
import { yavinJellyfinHandler } from "../..";
|
||||||
|
import RoleController from "../helper/role.controller";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -19,6 +20,7 @@ export class ExtendedClient extends Client {
|
|||||||
private commandFilePath = `${__dirname}/../commands`
|
private commandFilePath = `${__dirname}/../commands`
|
||||||
private jellyfin: JellyfinHandler
|
private jellyfin: JellyfinHandler
|
||||||
public voteController: VoteController = new VoteController(this, yavinJellyfinHandler)
|
public voteController: VoteController = new VoteController(this, yavinJellyfinHandler)
|
||||||
|
public roleController: RoleController = new RoleController(this)
|
||||||
public commands: Collection<string, CommandType> = new Collection()
|
public commands: Collection<string, CommandType> = new Collection()
|
||||||
private announcementChannels: Collection<string, TextChannel> = new Collection() //guildId to TextChannel
|
private announcementChannels: Collection<string, TextChannel> = new Collection() //guildId to TextChannel
|
||||||
private announcementRoleHandlerTask: Collection<string, ScheduledTask> = new Collection() //one task per guild
|
private announcementRoleHandlerTask: Collection<string, ScheduledTask> = new Collection() //one task per guild
|
||||||
|
Loading…
Reference in New Issue
Block a user