Skip to content

Gracefully handle user not being present in voice ban #1370

@sentry

Description

@sentry

When a user is voice banned without being a member of the server the bot still tries to move them to a different voice channel. We should gracefully handle the user not being in voice or not being in the server (the infraction still applies fine) by doing a membership check before attempting to move the user.

Sentry Issue: BOT-KT

AttributeError: 'User' object has no attribute 'move_to'
  File "discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "bot/exts/moderation/infraction/infractions.py", line 95, in voiceban
    await self.apply_voice_ban(ctx, user, reason)
  File "bot/decorators.py", line 135, in wrapper
    await func(*args, **kwargs)
  File "bot/exts/moderation/infraction/infractions.py", line 354, in apply_voice_ban
    await user.move_to(None, reason="Disconnected from voice to apply voiceban.")

Error executing command invoked by joe#6000: !voiceban [REDACTED] [REDACTED]

Metadata

Metadata

Labels

a: backendRelated to internal functionality and utilities (error_handler, logging, security, utils and core)a: moderationRelated to community moderation functionality: (moderation, defcon, verification)l: 0 - beginnerp: 2 - normalNormal Priorityt: bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions