def infraction_duration(self, event, infraction, duration): try: inf = Infraction.get(id=infraction) except Infraction.DoesNotExist: raise CommandFail('invalid infraction (try `!infractions recent`)') if inf.actor_id != event.author.id and event.user_level < CommandLevels.ADMIN: raise CommandFail('only administrators can modify the duration of infractions created by other moderators') if not inf.active: raise CommandFail('that infraction is not active and cannot be updated') expires_dt = parse_duration(duration, inf.created_at) converted = False if inf.type_ in [Infraction.Types.MUTE.index, Infraction.Types.BAN.index]: inf.type_ = Infraction.Types.TEMPMUTE if inf.type_ == Infraction.Types.MUTE.index else Infraction.Types.TEMPBAN converted = True elif inf.type_ not in [Infraction.Types.TEMPMUTE.index, Infraction.Types.TEMPBAN.index, Infraction.Types.TEMPROLE.index]: raise CommandFail('cannot set the duration for that type of infraction') inf.expires_at = expires_dt inf.save() self.queue_infractions() if converted: raise CommandSuccess('ok, I\'ve made that infraction temporary, it will now expire on {}'.format( inf.expires_at.isoformat() )) else: raise CommandSuccess('ok, I\'ve updated that infractions duration, it will now expire on {}'.format( inf.expires_at.isoformat() ))
def reason(self, event, infraction, reason): try: inf = Infraction.get(id=infraction) except Infraction.DoesNotExist: inf = None if inf is None or inf.guild_id != event.guild.id: event.msg.reply('Unknown infraction ID') return if not inf.actor_id: inf.actor_id = event.author.id if inf.actor_id != event.author.id and event.user_level < event.config.reason_edit_level: raise CommandFail('you do not have the permissions required to edit other moderators infractions') inf.reason = reason inf.save() raise CommandSuccess('I\'ve updated the reason for infraction #{}'.format(inf.id))
def reason(self, event, infraction, reason): try: inf = Infraction.get(id=infraction) except Infraction.DoesNotExist: inf = None if inf is None or inf.guild_id != event.guild.id: event.msg.reply('Unknown infraction ID') return if not inf.actor_id: inf.actor_id = event.author.id if inf.actor_id != event.author.id and event.user_level < CommandLevels.ADMIN: raise CommandFail( 'only administrators cannot modify other users infractions') inf.reason = reason inf.save() raise CommandSuccess( 'I\'ve updated the reason for infraction #{}'.format(inf.id))