Skip to main content

Lavalink and voice support for interactions.py

Project description

interactions-lavalink

Installation

  1. Download Java if you don't have it

  2. Download lavalink from this repo

  3. Configure application.yml file like here

  4. Download ext via pip install interactions-lavalink

Usage

Run lavalink via java -jar Lavalink.jar in same folder with application.yml file.

Create bot like example and run it.

import interactions

from interactions.ext.lavalink import VoiceState, VoiceClient



client = VoiceClient(...)



@client.event()

async def on_start():

    client.lavalink_client.add_node("127.0.0.1", 43421, "your_password", "eu")  # Copy host, port and password from `application.yml`



@client.event()

async def on_voice_state_update(before: VoiceState, after: VoiceState):

    ...



@client.command()

@interactions.option()

async def play(ctx: interactions.CommandContext, query: str):

    voice_state = client.get_user_voice_state(ctx.author.id)  # Can be `None` if not cached.

    player = await client.connect(ctx.guild_id, voice_state.channel_id)

    results = await player.node.get_tracks(f"ytsearch:{query}")

    player.add(requester=int(ctx.author.id), track=results["tracks"][0])

    await player.play()





client.start()

Example with using Extension here

Credits

Thanks EdVraz for VoiceState from voice ext

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

interactions-lavalink-0.0.1.tar.gz (19.2 kB view hashes)

Uploaded Source

Built Distribution

interactions_lavalink-0.0.1-py3-none-any.whl (20.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page