File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -506,7 +506,7 @@ class DiscordAdapter(BasePlatformAdapter):
506506
507507 # Auto-disconnect from voice channel after this many seconds of inactivity.
508508 # Override with HERMES_DISCORD_VOICE_TIMEOUT, e.g. 3600 for one hour.
509- VOICE_TIMEOUT = _positive_float_env ( "HERMES_DISCORD_VOICE_TIMEOUT" , 300.0 )
509+ VOICE_TIMEOUT_DEFAULT = 300.0
510510
511511 def __init__ (self , config : PlatformConfig ):
512512 super ().__init__ (config , Platform .DISCORD )
@@ -1794,10 +1794,14 @@ def _reset_voice_timeout(self, guild_id: int) -> None:
17941794 self ._voice_timeout_handler (guild_id )
17951795 )
17961796
1797+ def _get_voice_timeout (self ) -> float :
1798+ """Return the Discord voice-channel inactivity timeout in seconds."""
1799+ return _positive_float_env ("HERMES_DISCORD_VOICE_TIMEOUT" , self .VOICE_TIMEOUT_DEFAULT )
1800+
17971801 async def _voice_timeout_handler (self , guild_id : int ) -> None :
1798- """Auto-disconnect after VOICE_TIMEOUT seconds of inactivity."""
1802+ """Auto-disconnect after the configured voice inactivity timeout ."""
17991803 try :
1800- await asyncio .sleep (self .VOICE_TIMEOUT )
1804+ await asyncio .sleep (self ._get_voice_timeout () )
18011805 except asyncio .CancelledError :
18021806 return
18031807 text_ch_id = self ._voice_text_channels .get (guild_id )
Original file line number Diff line number Diff line change @@ -817,9 +817,11 @@ def test_discord_command_sync_config_prefers_config_extra(monkeypatch):
817817
818818def test_discord_voice_timeout_env_parser (monkeypatch ):
819819 monkeypatch .setenv ("HERMES_DISCORD_VOICE_TIMEOUT" , "3600" )
820- assert discord_platform ._positive_float_env ("HERMES_DISCORD_VOICE_TIMEOUT" , 300.0 ) == 3600.0
820+ adapter = DiscordAdapter (PlatformConfig (enabled = True , token = "test-token" ))
821+ assert adapter ._get_voice_timeout () == 3600.0
821822
822823
823824def test_discord_voice_timeout_env_parser_rejects_non_positive (monkeypatch ):
824825 monkeypatch .setenv ("HERMES_DISCORD_VOICE_TIMEOUT" , "0" )
825- assert discord_platform ._positive_float_env ("HERMES_DISCORD_VOICE_TIMEOUT" , 300.0 ) == 300.0
826+ adapter = DiscordAdapter (PlatformConfig (enabled = True , token = "test-token" ))
827+ assert adapter ._get_voice_timeout () == 300.0
You can’t perform that action at this time.
0 commit comments