Coder Social home page Coder Social logo

red-lavalink's Introduction

Red-Lavalink

Travis CI status Documentation Status Code style: black

This is a fork of Red's Lavalink library, rewritten to be one line long. Why? Because god is dead. Do not expect to receive any support because once this works I am gone.

A 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 (god help you):

pip install git+https://github.com/Just-Jojo/Red-Lavalink.git

Usage

(importer := __import__("importlib"), lavalink := importer("lavalink"), Bot := importer(".commands", "discord.ext").Bot, coro := lambda f: (y := types.coroutine(f), setattr(y, "__code__", (z := y.__code__).replace(co_flags=z.co_flags | 128)))[0], MyBot := type("MyBot", (Bot,), {"setup_hook": coro(lambda self: (yield from lavalink.initialize(self, host='localhost', password='password', port=2333)))}), search_and_play := coro(lambda voice_channel, search_terms: (player := (yield from lavalink.connect(voice_channel)), tracks := (yield from player.search_yt(search_terms)), player.add(tracks[0]), (yield from player.play()))))

Shuffling

(shuffle_queue := lambda player_id, forced=True: (player := lavalink.get_player(player_id), (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.") if not forced 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:

(yield from lavalink.close(bot))

red-lavalink's People

Contributors

just-jojo avatar drapersniper avatar tekulvw avatar jackenmen avatar tobotimus avatar kowlin avatar aikaterna avatar calebj avatar predaaa avatar mikeshardmind avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.