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):
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
Close
Hashes for interactions-lavalink-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1f37c5336df93c5c8955701f0fdb6a7243ab12eef3333554f96eaa65d038e7d |
|
MD5 | 3392e9301bf069eb073a3a9d5d484172 |
|
BLAKE2b-256 | 39fc6059ec0ef50d02e6d78eff4c14a81eca36ade5c212e34886f886856dcf5f |
Close
Hashes for interactions_lavalink-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3ad241acb617384f1467e39323ec7a168d6d0faf780ffffe54e3ea4a3d477a8 |
|
MD5 | 7c19b4ad5d14e9bb80abc3050345e5b6 |
|
BLAKE2b-256 | 14cbc485b7ee81d1b3d2478e097b5f79c373d80fbf8d5fc48df342129a3b161a |