By using /msgtoggle [on/off] :
When selected off - No one can message you
When selected on- Anyone can message you
Yeah, I upvote this suggestion. It will be a nice addition when you want nobody to message you.
I agree, and maybe add a /msgtoggle [on/off/friends] to add friends only mode
strange suggestion I made in the past but this is a duplicate:
https://cubedcraft.com/suggestions/view/178-settings--/
Suggestion closed.