mirror of
https://github.com/eRgo35/lyra.git
synced 2026-02-04 04:16:11 +01:00
queue
This commit is contained in:
@@ -7,7 +7,7 @@ edition = "2021"
|
|||||||
dotenv = "0.15.0"
|
dotenv = "0.15.0"
|
||||||
regex = "1.10.3"
|
regex = "1.10.3"
|
||||||
reqwest = "0.11.23"
|
reqwest = "0.11.23"
|
||||||
serenity = "0.12.0"
|
serenity = { version = "0.12.0", features = ["cache", "framework", "standard_framework", "voice"] }
|
||||||
songbird = { version = "0.4.0", features = ["builtin-queue", "serenity"] }
|
songbird = { version = "0.4.0", features = ["builtin-queue", "serenity"] }
|
||||||
symphonia = "0.5.3"
|
symphonia = "0.5.3"
|
||||||
tokio = { version = "1.35.1", features = ["macros", "rt-multi-thread", "signal"] }
|
tokio = { version = "1.35.1", features = ["macros", "rt-multi-thread", "signal"] }
|
||||||
|
|||||||
BIN
assets/lyra.pdn
Executable file
BIN
assets/lyra.pdn
Executable file
Binary file not shown.
@@ -6,6 +6,7 @@ use serenity::prelude::*;
|
|||||||
use crate::commands::misc::check_msg;
|
use crate::commands::misc::check_msg;
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
|
#[aliases(q)]
|
||||||
#[only_in(guilds)]
|
#[only_in(guilds)]
|
||||||
async fn leave(ctx: &Context, msg: &Message) -> CommandResult {
|
async fn leave(ctx: &Context, msg: &Message) -> CommandResult {
|
||||||
let guild_id = msg.guild_id.unwrap();
|
let guild_id = msg.guild_id.unwrap();
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ use serenity::model::prelude::*;
|
|||||||
use serenity::prelude::*;
|
use serenity::prelude::*;
|
||||||
use reqwest::Client as HttpClient;
|
use reqwest::Client as HttpClient;
|
||||||
use songbird::input::YoutubeDl;
|
use songbird::input::YoutubeDl;
|
||||||
|
use songbird::events::TrackEvent;
|
||||||
|
|
||||||
use crate::commands::misc::check_msg;
|
use crate::commands::{misc::check_msg, music::misc::TrackErrorNotifier};
|
||||||
|
|
||||||
pub struct HttpKey;
|
pub struct HttpKey;
|
||||||
|
|
||||||
@@ -32,7 +33,24 @@ async fn play(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
|
|||||||
|
|
||||||
let do_search = !url.starts_with("http");
|
let do_search = !url.starts_with("http");
|
||||||
|
|
||||||
let guild_id = msg.guild_id.unwrap();
|
let (guild_id, channel_id) = {
|
||||||
|
let guild = msg.guild(&ctx.cache).unwrap();
|
||||||
|
let channel_id = guild
|
||||||
|
.voice_states
|
||||||
|
.get(&msg.author.id)
|
||||||
|
.and_then(|voice_state| voice_state.channel_id);
|
||||||
|
|
||||||
|
(guild.id, channel_id)
|
||||||
|
};
|
||||||
|
|
||||||
|
let connect_to = match channel_id {
|
||||||
|
Some(channel) => channel,
|
||||||
|
None => {
|
||||||
|
check_msg(msg.reply(ctx, "Not in a voice channel").await);
|
||||||
|
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let http_client = {
|
let http_client = {
|
||||||
let data = ctx.data.read().await;
|
let data = ctx.data.read().await;
|
||||||
@@ -43,19 +61,23 @@ async fn play(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
|
|||||||
|
|
||||||
let manager = songbird::get(ctx)
|
let manager = songbird::get(ctx)
|
||||||
.await
|
.await
|
||||||
.expect("Songbird Voice client placed in at initialisation.")
|
.expect("Songbird Voice placed at init")
|
||||||
.clone();
|
.clone();
|
||||||
|
|
||||||
if let Some(handler_lock) = manager.get(guild_id) {
|
if let Ok(handler_lock) = manager.join(guild_id, connect_to).await {
|
||||||
let mut handler = handler_lock.lock().await;
|
let mut handler = handler_lock.lock().await;
|
||||||
|
|
||||||
|
handler.add_global_event(TrackEvent::Error.into(), TrackErrorNotifier);
|
||||||
|
|
||||||
let src = if do_search {
|
let src = if do_search {
|
||||||
// YoutubeDl::new_search(http_client, url)
|
|
||||||
YoutubeDl::new_ytdl_like("yt-dlp", http_client, url)
|
YoutubeDl::new_ytdl_like("yt-dlp", http_client, url)
|
||||||
} else {
|
} else {
|
||||||
YoutubeDl::new(http_client, url)
|
YoutubeDl::new(http_client, url)
|
||||||
};
|
};
|
||||||
let _ = handler.play_input(src.clone().into());
|
|
||||||
|
let _ = handler.enqueue_input(src.clone().into()).await;
|
||||||
|
|
||||||
|
// let _ = handler.play_input(src.clone().into());
|
||||||
|
|
||||||
check_msg(msg.channel_id.say(&ctx.http, "Playing song").await);
|
check_msg(msg.channel_id.say(&ctx.http, "Playing song").await);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user