#Wavelink not working?
1 messages · Page 1 of 1 (latest)
wavelink 0.9.10
following: https://guide.pycord.dev/voice/playing
code:
import discord
from discord.ext import commands
from discord import guild_only
from discord.commands import Option
import wavelink
class Music(commands.Cog):
def __init__(self, bot):
self.bot = bot
async def connect_nodes(self):
await self.bot.wait_until_ready()
await wavelink.NodePool.create_node(
bot=self.bot,
host='0.0.0.0',
port=2333,
password='youshallnotpass'
)
@commands.Cog.listener()
async def on_ready(self):
print("COG: Music is online")
await self.connect_nodes()
@commands.Cog.listener()
async def on_wavelink_node_ready(self, node: wavelink.Node):
print(f"{node.identifier} is ready.") # print a message
@commands.slash_command(name="play")
async def play(self, ctx, search: str):
vc = ctx.voice_client # define our voice client
if not vc: # check if the bot is not in a voice channel
vc = await ctx.author.voice.channel.connect(cls=wavelink.Player) # connect to the voice channel
if ctx.author.voice.channel.id != vc.channel.id: # check if the bot is not in the voice channel
return await ctx.respond("You must be in the same voice channel as the bot.") # return an error message
song = await wavelink.YouTubeTrack.search(query=search, return_first=True) # search for the song
if not song: # check if the song is not found
return await ctx.respond("No song found.") # return an error message
await vc.play(song) # play the song
await ctx.respond(f"Now playing: `{vc.source.title}`") # return a message
def setup(bot):
bot.add_cog(Music(bot))
Is that the latest?
Thats what came with the pip installation
iirc Master has the least buggy code with voice
Try updating again. Nodepool is available since long
Or try uninstalling and reinstalling