In old versions of Android (eg 4 or Jelly Bean) it was necessary to install third-party apps to obtain a Sleep mode or Do not disturb itself, since devices with these systems hardly had the option to silence the phone manually. Today's cell phones already incorporate a true "Do Not Disturb" or "Sleep Mode" mode, whose objective is to allow you to sleep or meditate without discomfort during the night or avoid interruptions in a meeting or important event, having the possibility of add exceptions in case of an emergency, and deactivate automatically after a certain time, according to a schedule or the moment you want (manual)..
Android's own sleep or do not disturb mode
This feature of Do not disturb or Sleep mode can be found in the same Android system settings, Notifications menu (the route may vary slightly from one device to another). There you will find the Do Not Disturb submenu, where you can activate this feature and modify its settings, as you can see in the screenshots above of my Samsung Galaxy A52 with Android 11.
The Sleep Mode option will allow you to temporarily disable the sound and vibration for calls, messages and notifications. By default, all this is disabled when you enable do not disturb mode..
The only default exceptions to this sleep mode are multimedia alarms and sounds (I presume it refers to the case that you voluntarily play music or video), which you can also disable if you prefer.
There is always the possibility that they want to call you in emergency while Do not disturb or sleep mode is activated, and for that the exceptions are available. As you see above, you can allow your contacts to call you or only your favorite contacts (which should be marked as such in the contact list). There is also the option to activate an exception when the same number calls you more than once in less than 15 minutes..
You can also add exceptions to be notified of messages or calls from WhatsApp or any other application, while do not disturb mode is activated. Unfortunately, here you cannot choose notifications for a certain contact: either you allow notifications for everyone, or you don't allow anyone. In this case, you may want to configure in the same WhatsApp who you mute and who you don't. This is a permanent change that should remain even when sleep mode is enabled.
As I said, you can set this do not disturb or sleep mode to turn on and off automatically. The default setting is every night from 10pm to 7am the next day, every day. However, in the time option you can choose what day and what time to enable it, in case you have a meeting or event scheduled where you do not want to be interrupted.
Finally, once the sleep mode is enabled, all the notifications will be hidden, being visible when the time is up in this way, but if you prefer you can activate them and make them show, something perhaps not recommended if you want to be focused during the time it lasts do not disturb mode.
How to stop music or audio player (eg YouTube, Spotify) automatically after falling asleep
Timer to turn off and turn on the cell phone's WiFi automatically
4 browsers with night mode that Chrome does not offer on Android