Click the icon of the server with the right button of the mouse and then choose the option Leave Server.
When you are gone, you are gone to all its channels, roles, and messages.
To leave a Discord server, open the server, click the server name at the top, select Leave Server, then confirm. On mobile, tap the three dots, choose Leave Server, and approve. You exit and no longer receive notifications or access.
If you want to leave a Discord server on Desktop/Web, right-click the server icon on the left sidebar, click Leave Server (red text), and confirm your action.
On the mobile version, tap the server, tap the three dots or the server name at the top, scroll down, and tap Leave Server, then confirm with Yes. Owners of a server can only leave it after transferring ownership to someone else.