Skip to content

Verify command shouldn't log tracebacks for DM failure. #763

@sentry

Description

@sentry

Sentry Issue: BOT-11

It currently uses log.exception() for all exceptions. Forbidden should be a special case and use a lower log level. A better approach may be to only handle Forbidden and re-raise all other exceptions (to defer it to the default command error handler). A finally block can be used to still delete the message afterwards.

        try:
            await ctx.author.send(WELCOME_MESSAGE)
        except Exception:
            # Catch the exception, in case they have DMs off or something
            log.exception(f"Unable to send welcome message to user {ctx.author}.")
Forbidden: 403 FORBIDDEN (error code: 50007): Cannot send messages to this user
  File "bot/cogs/verification.py", line 129, in accept_command
    await ctx.author.send(WELCOME_MESSAGE)
  File "discord/abc.py", line 856, in send
    data = await state.http.send_message(channel.id, content, tts=tts, embed=embed, nonce=nonce)
  File "discord/http.py", line 216, in request
    raise Forbidden(r, data)

Unable to send welcome message to user <REDACTED>.

Metadata

Metadata

Assignees

Labels

a: moderationRelated to community moderation functionality: (moderation, defcon, verification)good first issueGood for newcomersp: 3 - lowLow 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