Update versions for twilight and serenity-voice-model in songbird (#1075)
This commit is contained in:
12
Cargo.toml
12
Cargo.toml
@@ -4,7 +4,7 @@ description = "An async Rust library for the Discord voice API."
|
|||||||
documentation = "https://docs.rs/songbird"
|
documentation = "https://docs.rs/songbird"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
homepage = "https://github.com/serenity-rs/serenity"
|
homepage = "https://github.com/serenity-rs/serenity"
|
||||||
include = ["src/**/*.rs", "Cargo.toml"]
|
include = ["src/**/*.rs", "Cargo.toml", "build.rs"]
|
||||||
keywords = ["discord", "api", "rtp", "audio"]
|
keywords = ["discord", "api", "rtp", "audio"]
|
||||||
license = "ISC"
|
license = "ISC"
|
||||||
name = "songbird"
|
name = "songbird"
|
||||||
@@ -60,12 +60,12 @@ version = "0.7"
|
|||||||
optional = true
|
optional = true
|
||||||
features = ["voice", "gateway"]
|
features = ["voice", "gateway"]
|
||||||
path = "../"
|
path = "../"
|
||||||
version = "0.9.0-rc.2"
|
version = "0.9.0"
|
||||||
|
|
||||||
[dependencies.serenity-voice-model]
|
[dependencies.serenity-voice-model]
|
||||||
optional = true
|
optional = true
|
||||||
path = "../voice-model"
|
path = "../voice-model"
|
||||||
version = "0.9.0-rc.2"
|
version = "0.10"
|
||||||
|
|
||||||
[dependencies.spin_sleep]
|
[dependencies.spin_sleep]
|
||||||
optional = true
|
optional = true
|
||||||
@@ -82,12 +82,12 @@ default-features = false
|
|||||||
|
|
||||||
[dependencies.twilight-gateway]
|
[dependencies.twilight-gateway]
|
||||||
optional = true
|
optional = true
|
||||||
version = "0.1"
|
version = "0.2"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
[dependencies.twilight-model]
|
[dependencies.twilight-model]
|
||||||
optional = true
|
optional = true
|
||||||
version = "0.1"
|
version = "0.2"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
[dependencies.url]
|
[dependencies.url]
|
||||||
@@ -96,7 +96,7 @@ version = "2"
|
|||||||
|
|
||||||
[dependencies.xsalsa20poly1305]
|
[dependencies.xsalsa20poly1305]
|
||||||
optional = true
|
optional = true
|
||||||
version = "0.5"
|
version = "0.6"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
criterion = "0.3"
|
criterion = "0.3"
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ tracing = "0.1"
|
|||||||
tracing-subscriber = "0.2"
|
tracing-subscriber = "0.2"
|
||||||
serde_json = { version = "1" }
|
serde_json = { version = "1" }
|
||||||
tokio = { features = ["macros", "rt-threaded", "sync"], version = "0.2" }
|
tokio = { features = ["macros", "rt-threaded", "sync"], version = "0.2" }
|
||||||
twilight-gateway = "0.1"
|
twilight-gateway = "0.2"
|
||||||
twilight-http = "0.1"
|
twilight-http = "0.2"
|
||||||
twilight-model = "0.1"
|
twilight-model = "0.2"
|
||||||
twilight-standby = "0.1"
|
twilight-standby = "0.2"
|
||||||
|
|
||||||
[dependencies.songbird]
|
[dependencies.songbird]
|
||||||
path = "../.."
|
path = "../.."
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
//!
|
//!
|
||||||
//! # Twilight-rs attribution
|
//! # Twilight-rs attribution
|
||||||
//! ISC License (ISC)
|
//! ISC License (ISC)
|
||||||
//!
|
//!
|
||||||
//! Copyright (c) 2019, 2020 (c) The Twilight Contributors
|
//! Copyright (c) 2019, 2020 (c) The Twilight Contributors
|
||||||
//!
|
//!
|
||||||
//! Permission to use, copy, modify, and/or distribute this software for any purpose
|
//! Permission to use, copy, modify, and/or distribute this software for any purpose
|
||||||
//! with or without fee is hereby granted, provided that the above copyright notice
|
//! with or without fee is hereby granted, provided that the above copyright notice
|
||||||
//! and this permission notice appear in all copies.
|
//! and this permission notice appear in all copies.
|
||||||
//!
|
//!
|
||||||
//! THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
//! THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
//! REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
//! REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
//! FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
//! FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
@@ -21,10 +21,14 @@
|
|||||||
//! [basic lavalink bot]: https://github.com/twilight-rs/twilight/tree/trunk/lavalink/examples/basic-lavalink-bot
|
//! [basic lavalink bot]: https://github.com/twilight-rs/twilight/tree/trunk/lavalink/examples/basic-lavalink-bot
|
||||||
|
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
|
use songbird::{
|
||||||
|
input::{Input, Restartable},
|
||||||
|
tracks::{PlayMode, TrackHandle},
|
||||||
|
Songbird,
|
||||||
|
};
|
||||||
use std::{collections::HashMap, env, error::Error, future::Future, sync::Arc};
|
use std::{collections::HashMap, env, error::Error, future::Future, sync::Arc};
|
||||||
use songbird::{input::{Input, Restartable}, tracks::{PlayMode, TrackHandle}, Songbird};
|
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
use twilight_gateway::{Cluster, Event};
|
use twilight_gateway::{Cluster, Event, Intents};
|
||||||
use twilight_http::Client as HttpClient;
|
use twilight_http::Client as HttpClient;
|
||||||
use twilight_model::{channel::Message, gateway::payload::MessageCreate, id::GuildId};
|
use twilight_model::{channel::Message, gateway::payload::MessageCreate, id::GuildId};
|
||||||
use twilight_standby::Standby;
|
use twilight_standby::Standby;
|
||||||
@@ -59,7 +63,8 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
|
|||||||
let http = HttpClient::new(&token);
|
let http = HttpClient::new(&token);
|
||||||
let user_id = http.current_user().await?.id;
|
let user_id = http.current_user().await?.id;
|
||||||
|
|
||||||
let cluster = Cluster::new(token).await?;
|
let cluster =
|
||||||
|
Cluster::new(token, Intents::GUILD_MESSAGES | Intents::GUILD_VOICE_STATES).await?;
|
||||||
|
|
||||||
let shard_count = cluster.shards().len();
|
let shard_count = cluster.shards().len();
|
||||||
let songbird = Songbird::twilight(cluster.clone(), shard_count as u64, user_id);
|
let songbird = Songbird::twilight(cluster.clone(), shard_count as u64, user_id);
|
||||||
@@ -120,10 +125,7 @@ async fn join(msg: Message, state: State) -> Result<(), Box<dyn Error + Send + S
|
|||||||
|
|
||||||
let guild_id = msg.guild_id.ok_or("Can't join a non-guild channel.")?;
|
let guild_id = msg.guild_id.ok_or("Can't join a non-guild channel.")?;
|
||||||
|
|
||||||
let (_handle, success) = state
|
let (_handle, success) = state.songbird.join(guild_id, channel_id).await;
|
||||||
.songbird
|
|
||||||
.join(guild_id, channel_id)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
let content = match success?.recv_async().await {
|
let content = match success?.recv_async().await {
|
||||||
Ok(Ok(())) => format!("Joined <#{}>!", channel_id),
|
Ok(Ok(())) => format!("Joined <#{}>!", channel_id),
|
||||||
@@ -149,10 +151,7 @@ async fn leave(msg: Message, state: State) -> Result<(), Box<dyn Error + Send +
|
|||||||
|
|
||||||
let guild_id = msg.guild_id.unwrap();
|
let guild_id = msg.guild_id.unwrap();
|
||||||
|
|
||||||
state
|
state.songbird.leave(guild_id).await?;
|
||||||
.songbird
|
|
||||||
.leave(guild_id)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
state
|
state
|
||||||
.http
|
.http
|
||||||
@@ -190,8 +189,16 @@ async fn play(msg: Message, state: State) -> Result<(), Box<dyn Error + Send + S
|
|||||||
|
|
||||||
let content = format!(
|
let content = format!(
|
||||||
"Playing **{:?}** by **{:?}**",
|
"Playing **{:?}** by **{:?}**",
|
||||||
input.metadata.title.as_ref().unwrap_or(&"<UNKNOWN>".to_string()),
|
input
|
||||||
input.metadata.artist.as_ref().unwrap_or(&"<UNKNOWN>".to_string()),
|
.metadata
|
||||||
|
.title
|
||||||
|
.as_ref()
|
||||||
|
.unwrap_or(&"<UNKNOWN>".to_string()),
|
||||||
|
input
|
||||||
|
.metadata
|
||||||
|
.artist
|
||||||
|
.as_ref()
|
||||||
|
.unwrap_or(&"<UNKNOWN>".to_string()),
|
||||||
);
|
);
|
||||||
|
|
||||||
state
|
state
|
||||||
@@ -228,20 +235,19 @@ async fn pause(msg: Message, state: State) -> Result<(), Box<dyn Error + Send +
|
|||||||
let guild_id = msg.guild_id.unwrap();
|
let guild_id = msg.guild_id.unwrap();
|
||||||
|
|
||||||
let store = state.trackdata.read().await;
|
let store = state.trackdata.read().await;
|
||||||
|
|
||||||
let content = if let Some(handle) = store.get(&guild_id) {
|
let content = if let Some(handle) = store.get(&guild_id) {
|
||||||
let info = handle.get_info()?
|
let info = handle.get_info()?.await?;
|
||||||
.await?;
|
|
||||||
|
|
||||||
let paused = match info.playing {
|
let paused = match info.playing {
|
||||||
PlayMode::Play => {
|
PlayMode::Play => {
|
||||||
let _success = handle.pause();
|
let _success = handle.pause();
|
||||||
false
|
false
|
||||||
}
|
},
|
||||||
_ => {
|
_ => {
|
||||||
let _success = handle.play();
|
let _success = handle.play();
|
||||||
true
|
true
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let action = if paused { "Unpaused" } else { "Paused" };
|
let action = if paused { "Unpaused" } else { "Paused" };
|
||||||
@@ -283,7 +289,7 @@ async fn seek(msg: Message, state: State) -> Result<(), Box<dyn Error + Send + S
|
|||||||
let position = msg.content.parse::<u64>()?;
|
let position = msg.content.parse::<u64>()?;
|
||||||
|
|
||||||
let store = state.trackdata.read().await;
|
let store = state.trackdata.read().await;
|
||||||
|
|
||||||
let content = if let Some(handle) = store.get(&guild_id) {
|
let content = if let Some(handle) = store.get(&guild_id) {
|
||||||
if handle.is_seekable() {
|
if handle.is_seekable() {
|
||||||
let _success = handle.seek_time(std::time::Duration::from_secs(position));
|
let _success = handle.seek_time(std::time::Duration::from_secs(position));
|
||||||
@@ -360,7 +366,7 @@ async fn volume(msg: Message, state: State) -> Result<(), Box<dyn Error + Send +
|
|||||||
}
|
}
|
||||||
|
|
||||||
let store = state.trackdata.read().await;
|
let store = state.trackdata.read().await;
|
||||||
|
|
||||||
let content = if let Some(handle) = store.get(&guild_id) {
|
let content = if let Some(handle) = store.get(&guild_id) {
|
||||||
let _success = handle.set_volume(volume as f32);
|
let _success = handle.set_volume(volume as f32);
|
||||||
format!("Set the volume to {}", volume)
|
format!("Set the volume to {}", volume)
|
||||||
|
|||||||
Reference in New Issue
Block a user