auric 0.0.1-alpha
auric: ^0.0.1-alpha copied to clipboard
Lavalink v4 client for Dart with multi-source music support (YouTube, Spotify, Apple Music, SoundCloud). Built from scratch with audio filters and queue management.
Auric #
A Lavalink v4 client for Dart. Built from scratch because the existing ones were kinda mid.
What it does #
Lets you search and play music from basically anywhere:
- YouTube / YouTube Music (
yt,ytm) - SoundCloud (
sc) - Spotify (
sp) - Apple Music (
am) - Deezer (
dz) - Yandex Music (
ym) - Bandcamp (
bc) - Twitch (
tw) - Vimeo (
vm)
Also has audio filters if you're into that:
- Equalizer (15-band, presets included)
- Timescale (nightcore, vaporwave, etc)
- Karaoke (removes vocals mostly)
- 8D audio rotation
- Tremolo, vibrato, distortion
- Channel mixing
- Low pass filter
Other stuff:
- Session resuming (so your bot doesn't die when it restarts)
- Real-time events
- Queue management
- Playlist loading
- Pure Dart, no extra dependencies
- Actually supports all the Lavalink v4 REST stuff
Installation #
Add this to your pubspec.yaml:
dependencies:
auric:
path: ../auric
Quick Start #
import 'package:auric/auric.dart';
void main() async {
final auric = AuricClient(
host: 'localhost',
port: 2333,
password: 'youshallnotpass',
userId: 'your-bot-id',
);
await auric.connect(enableResuming: true);
// search apple music for despacito
final query = SearchQuery.parse('am despacito');
final result = await auric.loadTracks(query.toLavalinkQuery());
// play it
final player = auric.getPlayer('guild-id');
await player.play(result.tracks!.first);
// make it nightcore because why not
await player.setFilters(Timescale.nightcore().toJson());
}
Multi-Source Usage #
Just prefix your search with the source code:
final query = SearchQuery.parse('am never gonna give you up');
final result = await auric.loadTracks(query.toLavalinkQuery());
Examples:
!play am despacito -> searches Apple Music
!play sp imagine dragons -> searches Spotify
!play yt rick roll -> searches YouTube
!play sc dubstep -> searches SoundCloud
!play despacito -> defaults to SoundCloud
How to use #
AuricClient #
final auric = AuricClient(
host: 'localhost',
port: 2333,
password: 'youshallnotpass',
userId: 'bot-id',
);
await auric.connect(enableResuming: true);
MusicSources #
// all available sources
MusicSources.all;
// parse prefix from command
final source = MusicSources.parseCommandPrefix('am');
// format a search query
MusicSources.formatSearch(MusicSources.appleMusic, 'despacito');
// -> "amsearch:despacito"
SearchQuery #
final query = SearchQuery.parse('am despacito');
print(query.source.displayName); // "Apple Music"
print(query.query); // "despacito"
print(query.toLavalinkQuery()); // "amsearch:despacito"
// no prefix = defaults to SoundCloud
final query2 = SearchQuery.parse('hello');
PlayerController #
final player = auric.getPlayer('guild-id');
// playback controls
await player.play(track);
await player.pause();
await player.resume();
await player.stop();
await player.seek(Duration(seconds: 30));
await player.setVolume(150);
// queue stuff
player.addToQueue(track);
player.shuffleQueue();
await player.playNext();
await player.skipTo(5);
// filters
await player.setFilters(Equalizer.bassBoost().toJson());
await player.clearFilters();
Filters #
// nightcore
await player.setFilters(Timescale.nightcore().toJson());
// bass boost
await player.setFilters(Equalizer.bassBoost().toJson());
// 8d audio
await player.setFilters(Rotation.slow().toJson());
// stack multiple filters
await player.setFilters(FilterConfig(
timescale: Timescale.nightcore(),
equalizer: Equalizer.bassBoost(),
rotation: Rotation.fast(),
).toJson());
Lavalink setup #
You'll need Lavalink running with the right plugins. Here's a basic config:
server:
port: 2333
address: 0.0.0.0
lavalink:
server:
password: "youshallnotpass"
sources:
youtube: false
soundcloud: true
bandcamp: true
twitch: true
vimeo: true
http: true
plugins:
lavasrc:
sources:
spotify: true
applemusic: true
deezer: true
spotify:
clientId: "your-id"
clientSecret: "your-secret"
Note: You need the LavaSrc plugin for Spotify/Apple Music/Deezer to work.
Examples #
Basic usage #
import 'package:auric/auric.dart';
final auric = LavalinkClient(
host: 'localhost',
port: 2333,
password: 'youshallnotpass',
userId: 'bot-id',
);
await auric.connect();
final query = SearchQuery.parse('am despacito');
final result = await auric.loadTracks(query.toLavalinkQuery());
final player = auric.getPlayer('guild-id');
await player.play(result.tracks!.first);
Discord bot integration #
Check out example/discord_bot_example.dart for a full Discord bot implementation. It's got everything - play commands, queue management, filters, events, error handling, the works. Pretty much copy-paste ready if you need a music bot.
// snippet from the example
class MusicBot {
final LavalinkClient auric;
Future<void> handlePlayCommand(String guildId, String query) async {
final searchQuery = SearchQuery.parse(query);
final result = await auric.loadTracks(searchQuery.toLavalinkQuery());
final player = auric.getPlayer(guildId);
await player.play(result.tracks!.first);
}
}
More examples #
The example/ directory has:
basic_usage.dart- simple stuff to get startedmulti_source_search.dart- examples for all sourcesaudio_filters.dart- all the filter optionsqueue_management.dart- queue operationsdiscord_bot_example.dart- complete bot (this one's useful)
Also check example.dart for more.
License #
MIT
made by the milter team