Ongaku
A simple voice library for Hikari.
Ongaku is a voice library that allows for playing tracks from a lavalink server, using the Hikari discord API.
Ongaku tries to make everything as simple as possible for new users, but still having full access to add custom plugins and change (or create) session handlers.
Current Features
- Player control
- Playlists
- Queuing
- Adding songs.
- Shuffling the queue.
- Skipping a song or multiple.
- Deleting via position, or a track object.
- Clearing the queue.
- Requestors
- Setting the requestor of a track.
- Viewing requestor in events.
- Seeking/Reversing the tracks position.
- Volume control
- Looping (loops the same song over and over.)
- Filters (allows for changing the way audio plays and sounds.)
- Events
- Ready Event (when a session is online.)
- Player Update Event (when a player gets updated.)
- Statistics Event (about the server.)
- Track Start Event
- Track End Event
- Track Exception Event
- Track Stuck Event
- Empty Queue Event
- Next Queue Event
- Sessions
- BasicSessionHandler (Gives next available session)
- Others
- Traces (for debugging code.)
- Tests (Full test coverage.)
Future Features
- More session handlers: so there is more methods to use the sessions you have provided.
- Cache: a method to store information, and fetch it later, from events and rest actions.
- Changing channels: support for moving to different channels, without leaving and rejoining.
- Session failures: More control, like seeing why a session failed and allow for reconnecting, or resetting attempts.
Installation
To install ongaku, run the following command:
pip install -U hikari-ongaku
To check if ongaku has successfully installed or not, run the following command:
python3 -m ongaku
# On Windows you may need to run:
py -m ongaku
Getting Started
for more about how to get started see the docs.
import typing
import hikari
import ongaku
# Create a GatewayBot (RESTBot's are not supported.)
bot = hikari.GatewayBot(token="...")
# Give ongaku the bot.
client = ongaku.Client(bot)
@bot.listen()
async def message_event(
event: hikari.GuildMessageCreateEvent
) -> None:
# Ignore anything that has no content, is not a human, or is not in a guild.
if not event.content or not event.is_human or not event.guild_id:
return
# Ignore anything that is not the play command.
if not event.content.startswith("!play"):
return
# Get the query from play "command".
query = event.content.strip("!play ")
# Make sure the user is in a valid voice channel.
voice_state = bot.cache.get_voice_state(event.guild_id, event.author.id)
if not voice_state or not voice_state.channel_id:
await bot.rest.create_message(event.channel_id, "you are not in a voice channel.", reply=event.message)
return
# Fetch the track from the query string. (This searches just Youtube.)
result = await client.rest.load_track(f"ytsearch:{query}")
# If the song is `None` let them know it failed.
if result is None:
await bot.rest.create_message(event.channel_id, "No songs were found.", reply=event.message)
return
# Create a player (or if it already exists, grab that one!)
player = client.create_player(event.guild_id)
# Add the playlist, track or search result to the player.
if isinstance(result, typing.Sequence):
player.add(result[0])
else:
player.add(result)
# Tell the player to start playing the song!
await player.play()
await bot.rest.create_message(event.channel_id, f"Playing {player.queue[0].info.title}", reply=event.message)
Extensions
Ongaku has a few built-in extensions:
ext.checker- For checking if a song is a URL, or just a query.ext.injection- For injecting player instances into commands.ext.youtube- For setting or getting the token for your youtube config.
Issues and support
For general usage help or questions, see the #ongaku channel in the hikari discord, if you have found a bug or have a feature request, feel free to open an issue.
Links
Metadata
Release files for hikari-ongaku 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hikari_ongaku-1.0.4.tar.gz | 1.3 MB | Without provenance | Details for hikari_ongaku-1.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hikari_ongaku-1.0.4-py3-none-any.whl | Python 3 | none | any | Details for hikari_ongaku-1.0.4-py3-none-any.whl |
Total release size: 1.4 MB
Release files / hikari_ongaku-1.0.4.tar.gz
| Download URL | hikari_ongaku-1.0.4.tar.gz |
|---|---|
| Size | 1.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3261353c81eb0220f8455319d0ecb3e2969aa6ebf2ceb87d6eda4a8f95488010
|
|
BLAKE2b-256 checksum How to use checksums |
57a8d99a1153fbad13ee5fbf8e5579dd7072a71107992969bb4ab9a8e8633a42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / hikari_ongaku-1.0.4-py3-none-any.whl
| Download URL | hikari_ongaku-1.0.4-py3-none-any.whl |
|---|---|
| Size | 93.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ef2d78493a71d635d4b95e310d02ba0892bc41a8345cb133e3c80b0132b1aaba
|
|
BLAKE2b-256 checksum How to use checksums |
7b5e6548bab46742cb651080fcb3a67d9e31834b6238b932f7724644515bbcfd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Security for hikari-ongaku 1.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.