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.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5373baf9bb3ceaac73c118276d0d444ed29def4e7343ef4f1b566d5820883ce1 |
|
MD5 | 2cbd14522aab6a1a3e0faba6fd11b3da |
|
BLAKE2b-256 | c83cddafeb50ba05d32efb18559d524d7af23128f05fc4c5e55c2246908f8954 |
Close
Hashes for interactions_lavalink-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c701aaae5ec46ebdd64b5102eee87d6de35a92efadce82e0cc9b1eb4b6ef8b9f |
|
MD5 | f47a3d84529c7f40bb6f91c0d66f90f0 |
|
BLAKE2b-256 | 8acb59239ffecc483ec63bbaffec36f9eaf71de5c8b71ab828a745c720f8f788 |