WIP: feat/20-reactions-for-roles #59

Draft
kenobi wants to merge 16 commits from feat/20-reactions-for-roles into master
Showing only changes of commit a50ac1716f - Show all commits

View File

@ -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
})

method called reactions but parameter is singular

method called reactions but parameter is singular
1f372b0aacd94d6eb5cfbe2e72f61dfdf77c1a31
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)