API to Check if a DM Can Be Sent (Bot or User Account) – Avoid Unnecessary 403s #7999
Replies: 2 comments 1 reply
-
|
exposing this would let bad actors target only people with dms enabled, which would reduce the amount of requests they send and probably make it easier to go under the radar, i assume that's why they've never added this |
Beta Was this translation helpful? Give feedback.
-
|
This could be part of the Create DM endpoint, which I just found always returns the channel with minimal information about the user. This endpoint could return a 400 if the user's dm is closed and 403 if blocked (like sending currently). Maybe even specific JSON codes to determine whether the user doesn't share a server/app or not open in general. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
Currently, when a bot or normal user account tries to DM someone who has DMs blocked, the Discord API returns a 403 Forbidden (
discord.Forbiddenin discord.py). There is no way to check ahead of time whether a DM is allowed, forcing developers and users to rely on exception handling whenever a DM is sent.Example Scenario (Bot):
This works, but it’s inefficient and noisy for bots or scripts that need to check DM capability frequently.
Proposed Feature:
Add an API endpoint or property to check if a DM can be sent before attempting to send it, for both bot accounts and normal user accounts. Example usage:
Benefits:
Notes:
Userobject or a dedicated API endpoint accessible to both bot and user accounts.Steps to Reproduce
Expected Behavior
Current Behavior
Screenshots/Videos
Client and System Information
Why?
Even if the efficiency isn’t a huge win, it’s more about predictable behavior and avoiding unnecessary noise in production environments, especially for bots that handle many users.
Beta Was this translation helpful? Give feedback.
All reactions