Maintained wavelink fork for pycord

Overview

Pycord.Wavelink

Wavelink is robust and powerful Lavalink wrapper for Pycord! Wavelink features a fully asynchronous API that's intuitive and easy to use.

Support

For support using Pycord.WaveLink, please join the official support server on Discord.

Discord

Installation

The following commands are currently the valid ways of installing WaveLink.

WaveLink requires Python 3.8+

Windows

py -3.9 -m pip install pycord.wavelink --pre

Linux

python3.9 -m pip install pycord.wavelink --pre

Getting Started

A quick and easy bot example:

import pycord.wavelink as wavelink
from discord.ext import commands

class Bot(commands.Bot):
    def __init__(self):
        super().__init__(command_prefix='>?')

    async def on_ready(self):
        print('Bot is ready!')

class Music(commands.Cog):
    """Music cog to hold Wavelink related commands and listeners."""
    def __init__(self, bot: commands.Bot):
        self.bot = bot
        bot.loop.create_task(self.connect_nodes())

    async def connect_nodes(self):
        """Connect to our Lavalink nodes."""
        await self.bot.wait_until_ready()
        await wavelink.NodePool.create_node(
            bot=bot,
            host='0.0.0.0',
            port=2333,
            password='YOUR_LAVALINK_PASSWORD',
        )

    @commands.Cog.listener()
    async def on_wavelink_node_ready(self, node: wavelink.Node):
        """Event fired when a node has finished connecting."""
        print(f'Node: <{node.identifier}> is ready!')

    @commands.command()
    async def play(self, ctx: commands.Context, *, search: wavelink.YouTubeTrack):
        """Play a song with the given search query.
        If not connected, connect to our voice channel.
        """
        if not ctx.voice_client:
            vc: wavelink.Player = await ctx.author.voice.channel.connect(cls=wavelink.Player)
        else:
            vc: wavelink.Player = ctx.voice_client
        await vc.play(search)

bot = Bot()
bot.add_cog(Music(bot))
bot.run('YOUR_BOT_TOKEN')
Comments
  • Make Pycord.Wavelink a Pycord extension

    Make Pycord.Wavelink a Pycord extension

    Summary

    This will move all files into the discord/ext/wavelink namespace. This is a way better implementation than the current one. It also allows seamless migration from the original library without using an alias when importing wavelink.

    Following was tested:

    • Installation
    • Playing a track

    Docs Build wasn't tested.

    Checklist

    • [x] If code changes were made then they have been tested.
      • [x] I have updated the documentation to reflect the changes.
    • [ ] If type: ignore comments were used, a comment is also left explaining why
    • [x] This PR fixes an issue. #15
    • [ ] This PR adds something new (e.g. new method or parameters).
    • [x] This PR is a breaking change (e.g. methods or parameters removed/renamed)
    • [ ] This PR is not a code change (e.g. documentation, README, typehinting, examples, ...)

    Further possible improvements

    To reflect this change, the pypi name and GitHub repo should be renamed to pycord-ext-wavelink or py-cord-ext-wavelink.

    Due to the early state of the library it should be possible and all users would adapt to this change.

    opened by Luc1412 16
  • Make wavelink a pycord extension

    Make wavelink a pycord extension

    I think a smart implementation of this library would be as an extension by moving it into the discord/ext/wavelink namespace.

    Also the library name currently is a bit unconventional. pycord-ext-wavelink or py-cord-ext-wavelink would be better by following the naming conventions from Danny (menu extension)

    opened by Luc1412 4
  • Revert

    Revert "Improve the connect, move, and is_connected methods"

    Reverts Pycord-Development/Pycord.Wavelink#34

    The library seems to have broken after the mentioned PR. 1 previous version works perfectly without any code changes

    Error-

    Traceback (most recent call last):
      File "/home/container/.local/lib/python3.10/site-packages/discord/ext/commands/core.py", line 179, in wrapped
        ret = await coro(*args, **kwargs)
      File "/home/container/Cogs/Music.py", line 142, in play
        await vc.play(vc.queue.get())
      File "/home/container/.local/lib/python3.10/site-packages/pycord/wavelink/player.py", line 247, in play
        "guildId": str(self.guild.id),
      File "/home/container/.local/lib/python3.10/site-packages/pycord/wavelink/player.py", line 107, in guild
        return self.channel.guild
    AttributeError: 'NoneType' object has no attribute 'guild'
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "/home/container/.local/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 335, in invoke
        await ctx.command.invoke(ctx)
      File "/home/container/.local/lib/python3.10/site-packages/discord/ext/commands/core.py", line 916, in invoke
        await injected(*ctx.args, **ctx.kwargs)
      File "/home/container/.local/lib/python3.10/site-packages/discord/ext/commands/core.py", line 188, in wrapped
        raise CommandInvokeError(exc) from exc
    discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'guild'
    
    opened by Om1609 2
  • VOICE_SERVER_UPDATE and VOICE_STATE_UPDATE events of discord are not dispatched to lavalink

    VOICE_SERVER_UPDATE and VOICE_STATE_UPDATE events of discord are not dispatched to lavalink

    No song is playing on the channel after the client sends the request and the server is sending connected: False in websocket event.

    2022-02-08 15:25:43,642 - pycord.wavelink.websocket - op: event:: {'op': 'event', 'type': 'TrackStartEvent', 'track': 'QAAAkgIALExpb25lbCBSaWNoaWUgLSBIZWxsbyAoT2ZmaWNpYWwgTXVzaWMgVmlkZW8pAAxsaW9uZWxyaWNoaWUAAAAAAAT9WAALbUhPTk5jWmJ3RFkAAQAraHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1tSE9OTmNaYndEWQAHeW91dHViZQAAAAAAAAAA', 'guildId': '822344738958344204'}
    2022-02-08 15:25:48,459 - pycord.wavelink.websocket - Received Payload:: <{"op":"playerUpdate","state":{"connected":false,"position":0,"time":1644314148103},"guildId":"822344738958344204"}>
    2022-02-08 15:25:48,461 - pycord.wavelink.websocket - op: playerUpdate:: {'op': 'playerUpdate', 'state': {'connected': False, 'position': 0, 'time': 1644314148103}, 'guildId': '822344738958344204'}
    2022-02-08 15:25:53,581 - pycord.wavelink.websocket - Received Payload:: <{"op":"playerUpdate","state":{"connected":false,"position":0,"time":1644314153102},"guildId":"822344738958344204"}>
    2022-02-08 15:25:53,584 - pycord.wavelink.websocket - op: playerUpdate:: {'op': 'playerUpdate', 'state': {'connected': False, 'position': 0, 'time': 1644314153102}, 'guildId': '822344738958344204'}
    2022-02-08 15:25:58,378 - pycord.wavelink.websocket - Received Payload:: <{"op":"playerUpdate","state":{"connected":false,"position":0,"time":1644314158102},"guildId":"822344738958344204"}>
    2022-02-08 15:25:58,380 - pycord.wavelink.websocket - op: playerUpdate:: {'op': 'playerUpdate', 'state': {'connected': False, 'position': 0, 'time': 1644314158102}, 'guildId': '822344738958344204'}
    
    
    opened by TheShubhendra 2
  • Bug in Node.get_player

    Bug in Node.get_player

       async def get_player(self, obj: Union[ApplicationContext, discord.Guild]):
            if isinstance(obj, ApplicationContext):
                obj = obj.guild
            print(wavelink.NodePool._nodes)
            for node in wavelink.NodePool._nodes.values():
                player = node.get_player(obj)
                if player is not None:
                    return player
            if player is None:
                player = Player(obj)
            return player 
    

    I am trying to retrieve the player from the Pool using the above code but it's returning me the following error.

       player = node.get_player(obj)
      File "/home/pi/.local/lib/python3.10/site-packages/pycord/wavelink/pool.py", line 308, in get_player
        if player.guild == guild:
      File "/home/pi/.local/lib/python3.10/site-packages/pycord/wavelink/player.py", line 107, in guild
        return self.channel.guild
    AttributeError: 'NoneType' object has no attribute 'guild'
    
    opened by TheShubhendra 1
  • Missing some Wavelink objects

    Missing some Wavelink objects

    wavelink.Client, wavelink.eqs.Equalizer, wavelink.meta.WavelinkMixin, and wavelink.events (such as wavelink.events.TrackEnd) were not brought over into the pycord version of wavelink

    invalid wontfix 
    opened by KosmicAnomaly 1
  • `SoundCloudTrack` Always Raises `BadArgument`

    `SoundCloudTrack` Always Raises `BadArgument`

    Summary

    Every time I search for a song in SoundCloud with wavelink.SoundCloudTrack, it never returns anything. Rather, it raises a BadArgument exception stating that it could not find any songs matching that query.

    Reproduction Steps

    1. Run the Minimal Reproducible Code
    2. Join a VC that your bot can join
    3. Run the play command with your query of choice

    Minimal Reproducible Code

    Use the example code but replace the type annotation for the search argument from wavelink.YouTubeTrack to wavelink.SoundCloudTrack.

    Expected Results

    The bot would join the VC and play the song from a lavalink server's SoundCloud search with the query

    Actual Results

    Ignoring exception in command play:
    Traceback (most recent call last):
      File "ProjectDir/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 335, in invoke
        await ctx.command.invoke(ctx)
      File "ProjectDir/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 902, in invoke
        await self.prepare(ctx)
      File "ProjectDir/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 832, in prepare
        await self._parse_arguments(ctx)
      File "ProjectDir/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 747, in _parse_arguments
        kwargs[name] = await self.transform(ctx, param)
      File "ProjectDir/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 590, in transform
        return await run_converters(ctx, converter, argument, param)  # type: ignore
      File "ProjectDir/venv/lib/python3.8/site-packages/discord/ext/commands/converter.py", line 1183, in run_converters
        return await _actual_conversion(ctx, converter, argument, param)
      File "ProjectDir/venv/lib/python3.8/site-packages/discord/ext/commands/converter.py", line 1075, in _actual_conversion
        return await converter.convert(ctx, argument)
      File "ProjectDir/pycord/wavelink/tracks.py", line 203, in convert
        raise commands.BadArgument("Could not find any songs matching that query.")
    discord.ext.commands.errors.BadArgument: Could not find any songs matching that query.
    

    Intents

    None

    System Information

    Since I couldn't install the latest version, I, instead, cloned this repository to the latest commit (edaf4d7caedf797852d82d3e08faec9d89997ab7) and dragged the source code (the pycord directory inside of src) to the root project directory.

    - Python 3.8.5
    - py-cord v2.0.0-alpha
        - py-cord pkg_resources: v2.0.0a4688+g52fdbb1b
    - aiohttp v3.7.4.post0
    - system information: Darwin 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64
    
    opened by Makiyu-py 1
  • Get Spotify Tracks from YTMusic instead of YT

    Get Spotify Tracks from YTMusic instead of YT

    Summary

    YouTube Music searches and returns Soundtracks before Music videos. Due to this nature, the quality tends to be better on Youtube Music searches.

    Since Spotify is also primarily soundtracks based music streaming service, getting tracks from YTM seems more logical.

    I've tested it to an extent. And the initial results look promising. This should be implemented in conjunction to #24

    Checklist

    • [x] If code changes were made then they have been tested.
      • [ ] I have updated the documentation to reflect the changes.
    • [ ] If type: ignore comments were used, a comment is also left explaining why
    • [] This PR fixes an issue.
    • [x] This PR adds something new (e.g. new method or parameters).
    • [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed)
    • [ ] This PR is not a code change (e.g. documentation, README, typehinting, examples, ...)
    opened by Om1609 0
  • Add PlainTrack to __all__

    Add PlainTrack to __all__

    Summary

    Add PlainTrack to the __all__ variable so it is recognised by IDEs I'm not sure how it affected the working of the object earlier, but now the code does work 😅

    Checklist

    • [x] If code changes were made then they have been tested.
      • [ ] I have updated the documentation to reflect the changes.
    • [ ] If type: ignore comments were used, a comment is also left explaining why
    • [x] This PR fixes an issue.
    • [ ] This PR adds something new (e.g. new method or parameters).
    • [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed)
    • [ ] This PR is not a code change (e.g. documentation, README, typehinting, examples, ...)
    opened by Om1609 0
  • Subclass YTM Track from YT Track

    Subclass YTM Track from YT Track

    So apparently songs on YouTube music are there on Youtube too, with the exact same video id. In fact, Youtube Music is just a layer on top of Youtube.

    Subclassing YTM Track from YT Track gives it the thumbnail property. It is used to get the thumbnail of the video

    opened by Om1609 0
  • Create an attribute named self deafen

    Create an attribute named self deafen

    If you know many music bots use self deafen method to deafen them. I know we can manually deafen the bots in the server but it looks cool when the bot is on self deafen, so i will suggest to add an attribute named selfdeafen.

    opened by TheRealShreyash 1
  • Age Restricted Content Unplayable (YouTube)

    Age Restricted Content Unplayable (YouTube)

    Age Restricted content on YouTube appears to be unplayable currently. Lavalink shows that it loads whatever Age-Restricted video you throw at it, but there is no audio outputted by the bot.

    opened by remiteeple 0
Releases(1.0.0-dev)
Owner
Pycord Development
A team of developers working on maintaining pycord. Owned by @BobDotCom
Pycord Development
Black-hat with python

black-hat_python Advantages - More advance tool Easy to use allows updating tool update - run bash update.sh Here -: Command to install tool main- clo

Hackers Tech 2 Feb 10, 2022
Wordy is a Wordle-like Discord bot but with a twist.

Wordy Discord Bot Wordy is a Wordle-like Discord bot but with a twist. It already supports 6 languages from the beginning: English, Italian, French, G

The Coding Channel 2 Sep 06, 2022
Python powered spreadsheets

Marmir is powerful and fun Marmir takes Python data structures and turns them into spreadsheets. It is xlwt and google spreadsheets on steroids. It al

Brian Ray 170 Dec 14, 2022
Production Ontology Merging (PrOM) Framework

Production Ontology Merging (PrOM) Framework OWL 2 DL ontology merging framework tailored to the production domain Features preprocessing: translation

4 Nov 02, 2022
Use GitHub Actions to create a serverless service.

ActionServerless - Use GitHub Actions to create a serverless service ActionServerless is an action to do some computing and then generate a string/JSO

107 Oct 28, 2022
This repository is used to simplify the process of cloning the SSM documents across the AWS regions.

SSM Cloner Introduction This module is created in order to simplify the process of copying the SSM documents from one region to another regions. As an

6 Jun 04, 2022
streamlit translator is used to detect and translate between languages created using gTTS, googletrans, pillow and streamlit python packages

Streamlit Translator Streamlit Translator is a simple translator app to detect and translate between languages. Streamlit Translator gets text and lan

Siva Prakash 5 Apr 05, 2022
Python wrapper for eBay API

python-ebay - Python Wrapper for eBay API This project intends to create a simple python wrapper around eBay APIs. Development and Download Sites The

Roopesh 99 Nov 16, 2022
Based Telegram Bot and Userbot To Play Music in Your Telegram Groups With Some Cool Extra Features! 🥰

CallMusicPlus69 This Repo base on! 🤗️ A CallsMusic Based Telegram Bot and Userbot To Play Music in Your Telegram Groups With Some Cool Extra Features

brut✘⁶⁹ // ユスフ 6 Jun 26, 2022
TikTok channel bulk ripper based on TikTok-Api and Youtube-dl. Some assembly may be required.

RipTok Script provided as is. Absolutely no guarantee. A TikTok ripper based on TikTokApi and YouTube-dl. Some assembly may be required. positional ar

32 Dec 24, 2022
Yet another discord-BOT

Note I have not added comments to the initial code as it is for my educational purpose. Use This is the code for a discord-BOT API py-cord-2.0.0a4178+

IRONMELTS 1 Dec 18, 2021
Singer Tap for dbt Artifacts built with the Meltano SDK

tap-dbt-artifacts tap-dbt-artifacts is a Singer tap for dbtArtifacts. Built with the Meltano SDK for Singer Taps.

Prratek Ramchandani 9 Nov 25, 2022
The Encoder Bot For Python

The_Encoder_Bot Configuration Add values in environment variables or add them in config.env.example and rename file to config.env. Basics API_ID - Get

8 Jan 01, 2022
A head unit UI designed to replace the RTx/SMEG/RNEG/NG4/RCC/NAC

HeadUnit UI (Come discuss about it on our Discord!) Intro This is the UI part of a headunit project from OpenLeo, based on python and kivy, it looks l

OpenLeo 6 Nov 23, 2022
Open Source Discord bot with many cool features like Weather, Balance, Avatar, User, Server, RP-commands, Gif search, YouTube search, VK post search etc.

Сокобот Дискорд бот с открытым исходным кодом. Содержит в себе экономику, полезные команды (!аватар, !юзер, !сервер и тд.), рп-команды (!обнять, !глад

serverok 2 Jan 16, 2022
A demo without 🚀 science, just simple UTXO spending logic.

Stuck TX Demo Docker container that runs 4 dogecoind to demonstrate "the stuck tx problem". Scenario A wallet sends out 3 transactions to a recipient

Patrick Lodder 2 Nov 16, 2021
Query Amalgamator over StackOverflow and YouTube

QASY Query Amalgamator over StackOverflow and YouTube Decription A software you can use to save your valuable time of googling the errors you encounte

1 Nov 07, 2021
"zpool iostats" for humans; find the slow parts of your ZFS pool

Getting the gist of zfs statistics vpool-demo.mp4 The ZFS command "zpool iostat" provides a histogram listing of how often it takes to do things in pa

Chad 57 Oct 24, 2022
Framework for creating and running trading strategies. Blatantly stolen copy of qtpylib to make it work for Indian markets.

_• Kinetick Trade Bot Kinetick is a framework for creating and running trading strategies without worrying about integration with broker and data str

Vinay 41 Dec 31, 2022
A battle-tested Django 2.1 project template with configurations for AWS, Heroku, App Engine, and Docker.

For information on how to use this project template, check out the wiki. {{ project_name }} Table of Contents Requirements Local Setup Local Developme

Lionheart Software 64 Jun 15, 2022