Depending on your needs, you can customize settings that allow or restrict privileges for Discord server members.
We will present those settings, and you can choose the settings that suit your needs.
The location of the settings
To access this section, you need to go to Settings → Privacy & Safety → Server Privacy Defaults.
The settings available
Allow direct messages from server members
This function allows or restricts the ability of a server member (of which you are part of - server) to directly message you. This functionality doesn't apply retroactively, meaning if you turn it on and off it will apply only for future server joins.
Enable message requests from server members you might not know
This setting allows or restricts a server member possibility of sending you a message requests. The setting in your account will apply only to new server joins.
Changing these settings for a server
If you want to change this setting for a server you are currently part of, you will need to go to Server Settings → Privacy Settings → Direct Messages On / Off OR Message Request On / Off.