1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//! # twilight-lavalink
//!
//! [![codecov badge][]][codecov link] [![discord badge][]][discord link] [![github badge][]][github link] [![license badge][]][license link] ![rust badge]
//!
//! `twilight-lavalink` is a client for [Lavalink] as part of the twilight
//! ecosystem.
//!
//! It includes support for managing multiple nodes, a player manager for
//! conveniently using players to send events and retrieve information for each
//! guild, and an HTTP module for creating requests using the [`http`] crate and
//! providing models to deserialize their responses. It will automatically
//! handle sending voice channel updates to Lavalink by processing events via
//! the [client's `process` method][`Lavalink::process`], which you must call
//! with every Voice State Update and Voice Server Update you receive.
//!
//! ## Features
//!
//! ### `http-support`
//!
//! The `http-support` feature adds support for the `http` module to return
//! request types from the [`http`] crate. This is enabled by default.
//!
//! ### TLS
//!
//! `twilight-lavalink` has features to enable [`tokio-tungstenite`]'s TLS
//! features. These features are mutually exclusive. `rustls-native-roots` is enabled by
//! default.
//!
//! #### `native`
//!
//! The `native` feature enables [`tokio-tungstenite`]'s `native-tls` feature.
//!
//! To enable `native`, do something like this in your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! twilight-lavalink = { default-features = false, features = ["native"], version = "0.2" }
//! ```
//!
//! #### `rustls-native-roots`
//!
//! The `rustls-native-roots` feature enables [`tokio-tungstenite`]'s `rustls-tls-native-roots` feature,
//! which uses [`rustls`] as the TLS backend and [`rustls-native-certs`] for root certificates.
//!
//! This is enabled by default.
//!
//! #### `rustls-webpki-roots`
//!
//! The `rustls-webpki-roots` feature enables [`tokio-tungstenite`]'s `rustls-tls-webpki-roots` feature,
//! which uses [`rustls`] as the TLS backend and [`webpki-roots`] for root certificates.
//!
//! This should be preferred over `rustls-native-roots` in Docker containers based on `scratch`.
//!
//! ### Tracing
//!
//! The `tracing` feature enables logging via the [`tracing`] crate.
//!
//! This is enabled by default.
//!
//! ## Examples
//!
//! Create a [client], add a [node], and give events to the client to [process]
//! events:
//!
//! ```rust,no_run
//! use futures_util::stream::StreamExt;
//! use std::{
//! env,
//! error::Error,
//! future::Future,
//! net::SocketAddr,
//! str::FromStr,
//! };
//! use twilight_gateway::{Event, Intents, Shard};
//! use twilight_http::Client as HttpClient;
//! use twilight_lavalink::{http::LoadedTracks, model::Play, Lavalink};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
//! let token = env::var("DISCORD_TOKEN")?;
//! let lavalink_host = SocketAddr::from_str(&env::var("LAVALINK_HOST")?)?;
//! let lavalink_auth = env::var("LAVALINK_AUTHORIZATION")?;
//! let shard_count = 1u64;
//!
//! let http = HttpClient::new(token.clone());
//! let user_id = http.current_user().exec().await?.model().await?.id;
//!
//! let lavalink = Lavalink::new(user_id, shard_count);
//! lavalink.add(lavalink_host, lavalink_auth).await?;
//!
//! let intents = Intents::GUILD_MESSAGES | Intents::GUILD_VOICE_STATES;
//! let (shard, mut events) = Shard::new(token, intents);
//! shard.start().await?;
//!
//! while let Some(event) = events.next().await {
//! lavalink.process(&event).await?;
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! There is also an example of a basic bot located in the [root of the
//! `twilight` repository][github examples link].
//!
//! [Lavalink]: https://github.com/freyacodes/Lavalink
//! [`http`]: https://crates.io/crates/http
//! [`rustls`]: https://crates.io/crates/rustls
//! [`rustls-native-certs`]: https://crates.io/crates/rustls-native-certs
//! [`tokio-tungstenite`]: https://crates.io/crates/tokio-tungstenite
//! [`webpki-roots`]: https://crates.io/crates/webpki-roots
//! [client]: Lavalink
//! [codecov badge]: https://img.shields.io/codecov/c/gh/twilight-rs/twilight?logo=codecov&style=for-the-badge&token=E9ERLJL0L2
//! [codecov link]: https://app.codecov.io/gh/twilight-rs/twilight/
//! [discord badge]: https://img.shields.io/discord/745809834183753828?color=%237289DA&label=discord%20server&logo=discord&style=for-the-badge
//! [discord link]: https://discord.gg/7jj8n7D
//! [github badge]: https://img.shields.io/badge/github-twilight-6f42c1.svg?style=for-the-badge&logo=github
//! [github examples link]: https://github.com/twilight-rs/twilight/tree/main/examples
//! [github link]: https://github.com/twilight-rs/twilight
//! [license badge]: https://img.shields.io/badge/license-ISC-blue.svg?style=for-the-badge&logo=pastebin
//! [license link]: https://github.com/twilight-rs/twilight/blob/main/LICENSE.md
//! [node]: Node
//! [process]: Lavalink::process
//! [rust badge]: https://img.shields.io/badge/rust-1.57+-93450a.svg?style=for-the-badge&logo=rust
pub use ;