Skip to content

Commit

Permalink
Should close #2265
Browse files Browse the repository at this point in the history
Thanks ole for pointing out the way to do this.
  • Loading branch information
BabyBoySnow committed Oct 13, 2023
1 parent 13e1878 commit 0823941
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion config/example_options.ini
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,12 @@ SelfDeafen = yes
LeaveInactiveVC = no

#Sets how long you'd like to wait before leaving a voice channel that is inactive.
# Time is in seconds.
#Time is in seconds.
LeaveInactiveVCTimeOut = 300

#Sets if if the bot should leave once all songs have finished playing.
LeaveAfterSong = no

[Files]
# Path to your i18n file. Do not set this if you do not know what it does.
i18nFile =
4 changes: 4 additions & 0 deletions musicbot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,10 @@ async def on_player_stop(self, player, **_):

async def on_player_finished_playing(self, player, **_):
log.debug("Running on_player_finished_playing")
if self.config.leave_after_song:
guild = player.voice_client.guild
if player.playlist.entries.__len__() == 0:
await self.disconnect_voice_client(guild)

# delete last_np_msg somewhere if we have cached it
if self.config.delete_nowplaying:
Expand Down
4 changes: 4 additions & 0 deletions musicbot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ def __init__(self, config_file):
"LeaveInactiveVCTimeOut",
fallback=ConfigDefaults.leave_inactiveVCTimeOut,
)
self.leave_after_song = config.getboolean(
"MusicBot", "LeaveAfterSong", fallback=ConfigDefaults.leave_after_song
)
self.searchlist = config.getboolean(
"MusicBot", "SearchList", fallback=ConfigDefaults.searchlist
)
Expand Down Expand Up @@ -530,6 +533,7 @@ class ConfigDefaults:
self_deafen = True
leave_inactiveVC = False
leave_inactiveVCTimeOut = 300
leave_after_song = False
defaultsearchresults = 3
footer_text = "Just-Some-Bots/MusicBot ({})".format(BOTVERSION)

Expand Down

0 comments on commit 0823941

Please sign in to comment.