Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cog-creators/red-lavalink
Lavalink client library used in Red-DiscordBot
https://github.com/cog-creators/red-lavalink
discord-py lavalink python3 red-discordbot
Last synced: 7 days ago
JSON representation
Lavalink client library used in Red-DiscordBot
- Host: GitHub
- URL: https://github.com/cog-creators/red-lavalink
- Owner: Cog-Creators
- License: gpl-3.0
- Created: 2018-03-11T21:36:13.000Z (almost 7 years ago)
- Default Branch: develop
- Last Pushed: 2024-09-04T16:43:01.000Z (4 months ago)
- Last Synced: 2024-12-08T16:52:58.273Z (14 days ago)
- Topics: discord-py, lavalink, python3, red-discordbot
- Language: Python
- Size: 292 KB
- Stars: 26
- Watchers: 11
- Forks: 22
- Open Issues: 2
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
============
Red-Lavalink
============.. image:: https://readthedocs.org/projects/red-lavalink/badge/?version=latest
:target: http://red-lavalink.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/ambv/black
:alt: Code style: blackA Lavalink client library written for Python 3.8 using the AsyncIO framework.
This library may be used for other projects as it contains no Red specific code or logic.However, it is important to note that this library only supports projects using discord.py.
To install::
pip install red-lavalink
*****
Usage
*****.. code-block:: python
import lavalink
from discord.ext.commands import Botclass MyBot(Bot):
async def setup_hook(self):
await lavalink.initialize(
self, host='localhost', password='password', port=2333
)async def search_and_play(voice_channel, search_terms):
player = await lavalink.connect(voice_channel)
tracks = await player.search_yt(search_terms)
player.add(tracks[0])
await player.play()*********
Shuffling
*********
.. code-block:: pythondef shuffle_queue(player_id, forced=True):
player = lavalink.get_player(player_id)
if not forced:
player.maybe_shuffle(sticky_songs=0)
"""
`player.maybe_shuffle` respects `player.shuffle`
And will only shuffle if `player.shuffle` is True.`player.maybe_shuffle` should be called every time
you would expect the queue to be shuffled.`sticky_songs=0` will shuffle every song in the queue.
"""
else:
player.force_shuffle(sticky_songs=3)
"""
`player.force_shuffle` does not respect `player.shuffle`
And will always shuffle the queue.`sticky_songs=3` will shuffle every song after the first 3 songs in the queue.
"""When shutting down, be sure to do the following::
await lavalink.close(bot)