Hello StackOverflow Community, I have a problem with my discord bot made with Python, I am using the wavelink and lavalink library to search and play the music but when I call the play function the bot does not play anything, the logs do not help me They do not show anything and lavalink does the correct search.
this my code
@commands.command()
async def play(self, ctx: commands.Context, *, query: str):
await ctx.defer()
if not ctx.voice_client:
if ctx.author.voice:
vc: wavelink.Player = await ctx.author.voice.channel.connect(cls=wavelink.Player)
else:
await ctx.reply('Please enter the voice channel', ephemeral=True, delete_after=1)
return
else:
vc: wavelink.Player = ctx.voice_client
if "&list=LL&" in query:
query = query[0:query.index("&list=LL&")]
if not hasattr(vc, "home"):
vc.home = ctx.channel
elif vc.home != ctx.channel:
await ctx.send(f"You can only play songs in {vc.home.mention}, as the player has already started there.")
return
try:
tracks: wavelink.Playlist = await wavelink.Playable.search(query, source="ytsearch")
# print(type(tracks))
if not tracks:
await ctx.send(f"{ctx.author.mention} - Could not find any tracks with that query. Please try again.")
return
except wavelink.LavalinkLoadException:
await ctx.reply("No existe")
if isinstance(tracks, wavelink.Playlist):
# tracks.track_extras(ctx=ctx)
added: int = await vc.queue.put_wait(tracks)
await ctx.send(f"Added the playlist **`{tracks.name}`** ({added} songs) to the queue.")
else:
track: wavelink.Playable = tracks[0]
track.ctx = ctx
await vc.queue.put_wait(track)
await ctx.send(f"Added **`{track}`** to the queue.")
# print(vc.queue.get())
if not vc.current:
# print(type(vc.queue.get()))
await vc.play(track = vc.queue.get(), volume=100)
logger.info(f'Connected to the voice channel at the {vc.guild.name}. AUTHOR - {ctx.author}')
try:
await ctx.message.delete()
except discord.HTTPException:
pass
Logs
lavalink | 2024-04-27T00:55:26.682Z INFO 1 --- [ XNIO-1 task-3] l.server.io.RequestLoggingFilter : GET /v4/loadtracks?identifier=ytsearch:adamas
lavalink | 2024-04-27T00:55:26.868Z INFO 1 --- [back-1-thread-1] c.s.d.l.s.y.YoutubeAccessTokenTracker : Updating YouTube visitor id (current is CgtiOHJzTUltLWZHdyjtk7GxBjIKCgJQQRIEGgAgDjoMCAEguP7l-tC9kpZm).
lavalink | 2024-04-27T00:55:26.868Z INFO 1 --- [ XNIO-1 task-3] l.server.io.RequestLoggingFilter : PATCH /v4/sessions/ng4gmbchjrryngtv/players/1230456028819357798?noReplace=False, payload={"track": {"encoded": "QAABMgMAi0xpU0HjgI5BREFNQVPjgI8tTVVTaUMgQ0xpUC3vvIhUVuOCouODi+ODoeOAjOOCveODvOODieOCouODvOODiOODu+OCquODs+ODqeOCpOODsyDjgqLjg6rjgrfjgrzjg7zjgrfjg6fjg7PjgI3jgqrjg7zjg5fjg4vjg7PjgrDjg4bjg7zjg57vvIkAFUxpU0EgT2ZmaWNpYWwgWW91VHViZQAAAAAAA2sAAAt2MnRtekV1VkV6OAABACtodHRwczovL3d3dy55b3V0dWJlLmNvbS93YXRjaD92PXYydG16RXVWRXo4AQA0aHR0cHM6Ly9pLnl0aW1nLmNvbS92aS92MnRtekV1VkV6OC9tYXhyZXNkZWZhdWx0LmpwZwAAB3lvdXR1YmUAAAAAAAAAAA==", "userData": {}}, "volume": 100, "position": 0, "endTime": null, "paused": false, "filters": {"equalizer": [{"band": 0, "gain": 0.0}, {"band": 1, "gain": 0.0}, {"band": 2, "gain": 0.0}, {"band": 3, "gain": 0.0}, {"band": 4, "gain": 0.0}, {"band": 5, "gain": 0.0}, {"band": 6, "gain": 0.0}, {"band": 7, "gain": 0.0}, {"band": 8, "gain": 0.0}, {"band": 9, "gain": 0.0}, {"band": 10, "gain": 0.0}, {"band": 11, "gain": 0.0}, {"band": 12, "gain": 0.0}, {"band": 13, "gain": 0.0}, {"band": 14, "gain": 0.0}]}}
lavalink | 2024-04-27T00:55:27.092Z INFO 1 --- [back-1-thread-1] c.s.d.l.s.y.YoutubeAccessTokenTracker : Updating YouTube visitor id succeeded, new one is CgtYZWNCeW94VlAtMCj_mbGxBjIKCgJQQRIEGgAgNToMCAEg3eXGrfOfk5Zm, next update will be after 600 seconds.
Can you give me any recommendations? What other alternatives can I use instead of wavelink?
I’m looking for a guide or to solve the problem.