WIP: feat/20-reactions-for-roles #59
@ -34,11 +34,16 @@ export default class RoleController {
|
||||
return this.removeRoleFromUser(guildMember, roleToRemove, guild.id, requestId)
|
||||
}
|
||||
|
||||
public async getAnnouncementRoleForGuild(guild: Guild, requestId: string): Promise<Maybe<Role>> {
|
||||
public async getAnnouncementRoleForGuild(guild: Guild, requestId: string): Promise<Role> {
|
||||
const mediaRole = this.getAnnounceRoleIdForGuild(guild.id)
|
||||
return guild.roles.fetch()
|
||||
const announcement_role = await guild.roles.fetch()
|
||||
.then(fetchedRoles => fetchedRoles.find(role => role.id === mediaRole))
|
||||
.catch(error => { logger.error(`Could not find announcement_role with id ${config.bot.announcement_role}. Error: ${error}`, { requestId, guildId: guild.id }) })
|
||||
.catch(error => {
|
||||
logger.error(`Could not find announcement_role with id ${config.bot.announcement_role}. Error: ${error}`, { requestId, guildId: guild.id })
|
||||
throw error
|
||||
})
|
||||
|
||||
if (!announcement_role) throw new Error(`Could not find announcement_role with id ${config.bot.announcement_role}.`)
|
||||
return announcement_role
|
||||
}
|
||||
|
||||
public async assignAnnouncementRolesFromReaction(guild: Guild, reaction: MessageReaction, requestId: string) {
|
||||
@ -46,8 +51,6 @@ export default class RoleController {
|
||||
logger.info("Managing roles", { guildId, requestId })
|
||||
|
||||
const announcementRole = await this.getAnnouncementRoleForGuild(guild, requestId)
|
||||
if (!announcementRole)
|
||||
throw new Error(`No announcementRole found in guild ${guildId}`)
|
||||
|
||||
const usersWhoWantRole: User[] = (await reaction.users.fetch()).filter(user => !user.bot).map(user => user)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user
method called reactions but parameter is singular
1f372b0aac