Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source must be an AudioSource not YouTubeTrack #234

Closed
Celiian opened this issue Jul 17, 2023 · 2 comments · Fixed by #254
Closed

source must be an AudioSource not YouTubeTrack #234

Celiian opened this issue Jul 17, 2023 · 2 comments · Fixed by #254

Comments

@Celiian
Copy link

Celiian commented Jul 17, 2023

Everything work pretty good with wavelink and i could listen to music with my bot but from times to times i get this error : source must be an AudioSource not YouTubeTrack, on whatever music i search and i can't do anything about it. When the error come once, i get it for a few hours and can't listen at all. Here's my play function if needed : `
async def playAction(ctx, musique, wavelink, reconnect_nodes, queue):
try:
player: wavelink.Player = ctx.guild.voice_client

if not player:
  player: wavelink.Player = await ctx.author.voice.channel.connect(
    cls=wavelink.Player)

if ctx.author.voice.channel.id != player.channel.id:
  return await ctx.respond("Vous devez être dans la même vocale que moi.",
                           ephemeral=True,
                           delete_after=3)

song = await wavelink.YouTubeTrack.search(query=musique, return_first=True)

if not song:
  return await ctx.respond("Aucun son trouvé.",
                           ephemeral=True,
                           delete_after=3)
if queue == [] and not player.is_playing():
  print(song.title)
  await player.play(song)
  await ctx.respond(f"Je joue actuellement : {song.title}")

else:
  queue.append(song)
  await ctx.respond(f"Musique ajouté a la liste d'attente : {song.title}"
                    )

except Exception as e:
print(e)
await ctx.respond(
f"Désole, un problème est survenu, je ne peux jouer de musique pour le moment."
)`

@chillymosh
Copy link
Contributor

Hi @Celiian I suggest you update to the latest version on github.

pip install -U git+https://github.com/PythonistaGuild/Wavelink.git

Please be aware that since 2.6.0 (github is 2.6.1) return_first has been removed and .search() methods will always return a list now. But this version should hopefully resolve your issues. If not, please let us know.

Just as an extra note if queue == [] is not really best practice, in Wavelink you can simply use if queue.is_empty .

Although in general Python if not queue is the more pythonic way to that check if a list was empty.

@EvieePy
Copy link
Member

EvieePy commented Jul 18, 2023

This issue occurs when you have connected your bot to a channel without passing cls=wavelink.Player to the connect method.

Check your other commands to make sure wherever you are connecting to a channel, you use cls=wavelink.Player

@EvieePy EvieePy linked a pull request Nov 27, 2023 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants