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.ymlfile 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):
await ctx.defer()
# NOTE: ctx.author.voice can be None if you runned a bot after joining the voice channel
player = await self.client.connect(ctx.author.voice.guild_id, ctx.author.voice.channel_id)
results = await player.node.get_tracks(f"ytsearch:{query}")
track = AudioTrack(results["tracks"][0], int(ctx.author.id))
player.add(requester=int(ctx.author.id), track=track)
await player.play()
await ctx.send(f"Now playing: `{track.title}`")
client.start()
Example with using Extension here
New methods/properties for interactions.py library
Member.voice - returns current member's VoiceState. It can be None if not cached.
Channel.voice_states - returns a list of voice states of the voice channel. Can be empty if not cached.
Guild.voice_states - returns a list of guild voice states. Can be empty if not cached.
Documentation
lavalink.py documentation lavalink.py repository
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file interactions-lavalink-0.0.2.tar.gz.
File metadata
- Download URL: interactions-lavalink-0.0.2.tar.gz
- Upload date:
- Size: 19.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1f37c5336df93c5c8955701f0fdb6a7243ab12eef3333554f96eaa65d038e7d
|
|
| MD5 |
3392e9301bf069eb073a3a9d5d484172
|
|
| BLAKE2b-256 |
39fc6059ec0ef50d02e6d78eff4c14a81eca36ade5c212e34886f886856dcf5f
|
File details
Details for the file interactions_lavalink-0.0.2-py3-none-any.whl.
File metadata
- Download URL: interactions_lavalink-0.0.2-py3-none-any.whl
- Upload date:
- Size: 19.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3ad241acb617384f1467e39323ec7a168d6d0faf780ffffe54e3ea4a3d477a8
|
|
| MD5 |
7c19b4ad5d14e9bb80abc3050345e5b6
|
|
| BLAKE2b-256 |
14cbc485b7ee81d1b3d2478e097b5f79c373d80fbf8d5fc48df342129a3b161a
|