def unmute(self, event, user, reason=None): # TOOD: eventually we should pull the role from the GuildMemberBackup if they arent in server member = event.guild.get_member(user) if member: if not event.config.temp_mute_role and not event.config.mute_role: raise CommandFail('mute is not setup on this server') roles = {event.config.temp_mute_role, event.config.mute_role } & set(member.roles) if not len(roles): raise CommandFail('{} is not muted'.format(member.user)) Infraction.update(active=False).where( (Infraction.guild_id == event.guild.id) & (Infraction.user_id == member.user.id) & (Infraction.type_ == Infraction.Types.TEMPMUTE) & (Infraction.active == 1)).execute() self.bot.plugins.get('ModLogPlugin').create_debounce( event, member.user.id, 'unmuted', actor=unicode(event.author), roles=roles) for role in roles: member.remove_role(role) if event.config.confirm_actions: event.msg.reply(u':ok_hand: {} is now unmuted'.format( member.user)) else: raise CommandFail('invalid user')
def on_guild_ban_remove(self, event): Infraction.update(active=False).where( (Infraction.guild_id == event.guild.id) & (Infraction.user_id == event.user.id) & (Infraction.type_ == Infraction.Types.TEMPBAN) & (Infraction.active == 1)).execute()