用于Red Discordbot的Lavalink客户端库

Red-Lavalink的Python项目详细描述


Travis CI statusDocumentation StatusCode style: black

使用Asyncio框架为Python3.5编写的Lavalink客户端库。 此库可能用于其他项目,因为它不包含特定于红色的代码或逻辑。

但是,需要注意的是,此库仅支持使用discord.py的项目。

要安装:

pip install red-lavalink

用法

importlavalinkfromdiscord.ext.commandsimportBotbot=Bot()@bot.eventasyncdefon_ready():lavalink.initialize(bot,host='localhost',password='password',rest_port=2332,ws_port=2333)asyncdefsearch_and_play(voice_channel,search_terms):player=awaitlavalink.connect(voice_channel)tracks=awaitplayer.search_yt(search_terms)player.add(tracks[0])awaitplayer.play()

洗牌

defshuffle_queue(player_id,forced=True):player=lavalink.get_player(player_id)ifnotforced: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.
        """

关机时,请确保执行以下操作:

await lavalink.close()

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java为什么运行按钮在Eclipse中不起作用?   java构造函数:实例变量是否为对象存储单独的值?   java使用jquery获取值   生产文件夹和源文件夹中的java单元测试   java递归问题这个解决方案正确吗?有更简单的解决方案吗?   java Android sqlite正在检索已选中中的行   javacom。谷歌。云数据存储。DatastoreException:请求缺少必需的身份验证凭据   java无法在Linux Ubuntu 12.04上运行maven2   在监视器的上下文中,被阻塞的线程在被notify()调用唤醒后在何处继续执行?   安卓如何从游标获取Bool(Java SQLite)   如何阻止rxjava runnable发出?   使用设备管理时应用程序中的java Android实例化异常