Add more autoplay songs when queue gets low
This commit is contained in:
parent
66bf2a6cc2
commit
07f49fa2b7
@ -9,6 +9,7 @@ from global_variables import (
|
||||
LAVALINK_PORT,
|
||||
LOG,
|
||||
)
|
||||
from ai_recommendations import add_song_recommendations
|
||||
|
||||
|
||||
class LavalinkVoiceClient(discord.VoiceProtocol):
|
||||
@ -193,6 +194,16 @@ class Music(commands.Cog):
|
||||
if guild is not None:
|
||||
await guild.voice_client.disconnect(force=True)
|
||||
|
||||
@lavalink.listener(lavalink.events.TrackEndEvent)
|
||||
async def on_track_end(self, event: lavalink.events.TrackEndEvent):
|
||||
guild_id = event.player.guild_id
|
||||
|
||||
if len(event.player.queue) <= 10 and guild_id in self.bot.autoplay:
|
||||
inputs = {}
|
||||
for song in event.player.queue[:10]:
|
||||
inputs[song.title] = song.author
|
||||
await add_song_recommendations(self.bot.user, event.player, 5, inputs)
|
||||
|
||||
|
||||
async def setup(bot):
|
||||
await bot.add_cog(Music(bot))
|
||||
|
Loading…
x
Reference in New Issue
Block a user