Lavalink and voice support for interactions.py
Project description
interactions-lavalink
Installation
-
Download Java if you don't have it
-
Download lavalink from this repo
-
Configure
application.yml
file like here -
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for interactions-lavalink-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9273eb3c3c662bf24581367a3068611d1d9ab2f36bb25f1e99dd464a3ea181d6 |
|
MD5 | cb8d6624b8c65331d1b3cd9b371a4c98 |
|
BLAKE2b-256 | 6d16a5c42d577397a2ac804a8e1faa1a2d46052917712772f068bfa218cdf6ed |
Close
Hashes for interactions_lavalink-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a90efc283c2d5e5687437f55eb0246d47452d7231b29003b97af36377cd6da83 |
|
MD5 | 104501101a15adf1b1939087e6d85e92 |
|
BLAKE2b-256 | 68107a8743ee80e3be07476851ce71f3b9633824248a47add6eeeb93a9a3fc89 |