Skip to content

Commit

Permalink
Bert leave sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
codeman1o1 committed Aug 17, 2024
1 parent a386e3c commit ebf76cd
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.env
*.log
bot/sounds/
2 changes: 1 addition & 1 deletion bot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ RUN pip install --no-cache-dir -r ./requirements.txt \

COPY . .

CMD [ "python", "-Bu", "./main.py"]
CMD [ "python", "-Bu", "main.py"]
12 changes: 11 additions & 1 deletion bot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,17 @@ async def on_wavelink_track_end(payload: wavelink.TrackEndEventPayload):
return

if not payload.player.queue:
await payload.player.disconnect()
try:
sounds = os.listdir("sounds")
except FileNotFoundError:
sounds = []
if payload.track.source != "local" and sounds:
bye_sound = await wavelink.Playable.search(
f"sounds/{choice(sounds)}", source=None
)
await payload.player.play(bye_sound[0])
else:
await payload.player.disconnect()


@bert.event
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ services:
- LAVALINK_SERVER_PASSWORD=${LAVALINK_PASSWORD}
volumes:
- ./lavalink.yml:/opt/Lavalink/application.yml
- ./bot/sounds:/opt/Lavalink/sounds
restart: unless-stopped

volumes:
Expand Down
1 change: 1 addition & 0 deletions lavalink.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ lavalink:
server:
sources:
youtube: false
local: true

0 comments on commit ebf76cd

Please sign in to comment.