TypeError: unsupported type annotation <class 'wavelink.tracks.YouTubeTrack'> #250
Replies: 5 comments
-
What python version are you using? 2.x requires at least 3.10 I'd suggest using wavelink 3 though if this is a fresh bot. Also you using Client which does not support Commands with Context, but you are also using tree which is for app_commands |
Beta Was this translation helpful? Give feedback.
-
For Wavelink 3 Docs You can install this version with: This is a release candidate build and will soon be the stable release. On Wavelink 3 you can use the following code as a guide: import discord
import wavelink
from discord import app_commands
class PlayableTransformer(app_commands.Transformer):
async def transform(self, interaction: discord.Interaction, query: str) -> wavelink.Search:
tracks: wavelink.Search = await wavelink.Playable.search(query)
return tracks
# Where your commands are...
@client.tree.command(name="play", description="plays the music")
async def play(interaction: discord.Interaction, search: app_commands.Transform[wavelink.Search, PlayableTransformer]) -> None:
# Do what you need to here first...
...
if not search:
# No tracks were found...
await interaction.response.send_message("Unable to find any tracks with that query", ephemeral=True)
return
if isinstance(search, wavelink.Playlist):
# search is a Playlist
# You can add the playlist directly to your queue...
...
else:
# search is a list of Playable
track: wavelink.Playable = search[0]
... |
Beta Was this translation helpful? Give feedback.
-
i am not using client i am using bot i just named the variable client and i just pip installed it |
Beta Was this translation helpful? Give feedback.
-
btw i meant i just pip installed wavelink |
Beta Was this translation helpful? Give feedback.
-
also my full script is `import datetime forbidden_words = ["shit", "fuck", "bitch", "damn", "ass", "asshole", "motherfucker", "fucker", "nigger"] # dont mind this this is for a swear filter lol async def send_message(message, user_message, is_private):
def contains_forbidden_word(text): def run_discord_bot():
|
Beta Was this translation helpful? Give feedback.
-
im trying to make a music bot with discord.py and im getting this error
the error:
TypeError: unsupported type annotation <class 'wavelink.tracks.YouTubeTrack'>
the command
@client.tree.command(name="play",description="plays the music")
async def play(ctx: commands.Context, *, search: wavelink.YouTubeTrack):
if not ctx.voice_client:
vc: wavelink.Player = await ctx.author.voice.channel.connect(cls=wavelink.Player)
else:
vc: wavelink.Player = await ctx.voice_client
Beta Was this translation helpful? Give feedback.
All reactions