@@ -612,6 +612,10 @@ class AgeGateUnsupported(BridgeError):
612612 """Platform does not support age gate."""
613613 pass
614614
615+ class AgeGateDisabled (BridgeError ):
616+ """NSFW rooms are disabled."""
617+ pass
618+
615619 def verify_message_content (self , message : UnifierMessageContent ):
616620 """Verifies a UnifierMessageContent object to ensure it is valid."""
617621
@@ -1049,6 +1053,8 @@ async def join_room(self, user, room, channel, webhook_id=None, platform='discor
10491053 raise self .NotAgeGated ('room is NSFW but channel is not NSFW' )
10501054 elif nsfw and not roominfo ['meta' ].get ('settings' , {}).get ('nsfw' , False ):
10511055 raise self .IsAgeGated ('room is not NSFW but channel is NSFW' )
1056+ elif nsfw and not self .__bot .config ['allow_nsfw_rooms' ]:
1057+ raise self .AgeGateDisabled ('NSFW rooms are disabled' )
10521058
10531059 limit = self .get_connections_limit (guild_id )
10541060
@@ -2106,6 +2112,8 @@ async def can_send(self, room, message, content, files, source='discord', is_fir
21062112 raise self .NotAgeGated ('room is NSFW but channel is not NSFW' )
21072113 elif nsfw and not roomdata ['meta' ].get ('settings' , {}).get ('nsfw' , False ):
21082114 raise self .IsAgeGated ('room is not NSFW but channel is NSFW' )
2115+ elif nsfw and not self .__bot .config ['allow_nsfw_rooms' ]:
2116+ raise self .AgeGateDisabled ('NSFW rooms are disabled' )
21092117
21102118 # Check if server is banned from the room
21112119 if str (server ) in roomdata ['meta' ]['banned' ]:
0 commit comments