mirror of
https://github.com/eRgo35/lyra.git
synced 2026-02-04 12:26:10 +01:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
21fe190921
|
|||
|
4a0184811e
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -892,7 +892,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lyra"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"dotenv",
|
||||
"openssl",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "lyra"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
3
scripts/cross-build.sh
Normal file
3
scripts/cross-build.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
cross build -r --target aarch64-unknown-linux-gnu
|
||||
3
scripts/launch.sh
Normal file
3
scripts/launch.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
nohup ./lyra > lyra.log 2> lyra.err < /dev/null &
|
||||
83
src/commands/music/loopcurrent.rs
Normal file
83
src/commands/music/loopcurrent.rs
Normal file
@@ -0,0 +1,83 @@
|
||||
use serenity::framework::standard::macros::command;
|
||||
use serenity::framework::standard::{Args, CommandResult};
|
||||
use serenity::model::prelude::*;
|
||||
use serenity::prelude::*;
|
||||
use songbird::tracks::LoopState;
|
||||
|
||||
use crate::commands::misc::check_msg;
|
||||
|
||||
#[command]
|
||||
#[aliases(loop)]
|
||||
#[only_in(guilds)]
|
||||
async fn loopcurrent(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
|
||||
let guild_id = msg.guild_id.unwrap();
|
||||
|
||||
let manager = songbird::get(ctx)
|
||||
.await
|
||||
.expect("Client placed at init")
|
||||
.clone();
|
||||
|
||||
|
||||
if let Some(handler_lock) = manager.get(guild_id) {
|
||||
let handler = handler_lock.lock().await;
|
||||
let queue = handler.queue();
|
||||
|
||||
let track = queue.current().unwrap().get_info().await;
|
||||
let is_looped = track.unwrap().loops;
|
||||
|
||||
|
||||
let count = match args.single::<usize>() {
|
||||
Ok(count) => count,
|
||||
Err(_) => 100,
|
||||
};
|
||||
|
||||
match is_looped {
|
||||
LoopState::Infinite => {
|
||||
let _ = queue.current().unwrap().disable_loop();
|
||||
|
||||
check_msg(
|
||||
msg.channel_id
|
||||
.say(
|
||||
&ctx.http,
|
||||
format!("Song unlooped."),
|
||||
)
|
||||
.await,
|
||||
);
|
||||
}
|
||||
LoopState::Finite(_) => {
|
||||
if count < 100 {
|
||||
let _ = queue.current().unwrap().loop_for(count);
|
||||
check_msg(
|
||||
msg.channel_id
|
||||
.say(
|
||||
&ctx.http,
|
||||
format!("Song looped forever (a very long time)."),
|
||||
)
|
||||
.await,
|
||||
)
|
||||
}
|
||||
else {
|
||||
let _ = queue.current().unwrap().enable_loop();
|
||||
|
||||
check_msg(
|
||||
msg.channel_id
|
||||
.say(
|
||||
&ctx.http,
|
||||
format!("Song looped {} times.", count),
|
||||
)
|
||||
.await,
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
check_msg(
|
||||
msg.channel_id
|
||||
.say(&ctx.http, "Not in a voice channel to play in")
|
||||
.await,
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -7,3 +7,6 @@ pub mod play;
|
||||
pub mod queue;
|
||||
pub mod skip;
|
||||
pub mod stop;
|
||||
pub mod loopcurrent;
|
||||
pub mod pause;
|
||||
pub mod resume;
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
use serenity::framework::standard::macros::command;
|
||||
use serenity::framework::standard::CommandResult;
|
||||
use serenity::model::prelude::*;
|
||||
use serenity::prelude::*;
|
||||
|
||||
use crate::commands::misc::check_msg;
|
||||
|
||||
#[command]
|
||||
#[only_in(guilds)]
|
||||
async fn pause(ctx: &Context, msg: &Message) -> CommandResult {
|
||||
let guild_id = msg.guild_id.unwrap();
|
||||
|
||||
let manager = songbird::get(ctx)
|
||||
.await
|
||||
.expect("Client placed at init")
|
||||
.clone();
|
||||
|
||||
if let Some(handler_lock) = manager.get(guild_id) {
|
||||
let handler = handler_lock.lock().await;
|
||||
let queue = handler.queue();
|
||||
let _ = queue.pause();
|
||||
|
||||
check_msg(
|
||||
msg.channel_id
|
||||
.say(
|
||||
&ctx.http,
|
||||
format!("Song paused."),
|
||||
)
|
||||
.await,
|
||||
);
|
||||
} else {
|
||||
check_msg(
|
||||
msg.channel_id
|
||||
.say(&ctx.http, "Not in a voice channel to play in")
|
||||
.await,
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ async fn play(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
|
||||
if let Ok(handler_lock) = manager.join(guild_id, connect_to).await {
|
||||
let mut handler = handler_lock.lock().await;
|
||||
|
||||
if let Err(err) = handler.deafen(true).await {println!("Failed to deafen: {:?}", err)};
|
||||
// if let Err(err) = handler.deafen(true).await {println!("Failed to deafen: {:?}", err)};
|
||||
handler.add_global_event(TrackEvent::Error.into(), TrackErrorNotifier);
|
||||
|
||||
let mut src = if is_search {
|
||||
@@ -73,7 +73,6 @@ async fn play(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
|
||||
let _ = handler.enqueue_input(src.clone().into()).await;
|
||||
|
||||
let metadata = src.aux_metadata().await.unwrap();
|
||||
// let _ = handler.play_input(src.clone().into());
|
||||
|
||||
check_msg(msg.channel_id.say(&ctx.http, format!("Playing song: {}", metadata.title.unwrap())).await);
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
use serenity::framework::standard::macros::command;
|
||||
use serenity::framework::standard::CommandResult;
|
||||
use serenity::model::prelude::*;
|
||||
use serenity::prelude::*;
|
||||
|
||||
use crate::commands::misc::check_msg;
|
||||
|
||||
#[command]
|
||||
#[only_in(guilds)]
|
||||
async fn resume(ctx: &Context, msg: &Message) -> CommandResult {
|
||||
let guild_id = msg.guild_id.unwrap();
|
||||
|
||||
let manager = songbird::get(ctx)
|
||||
.await
|
||||
.expect("Client placed at init")
|
||||
.clone();
|
||||
|
||||
if let Some(handler_lock) = manager.get(guild_id) {
|
||||
let handler = handler_lock.lock().await;
|
||||
let queue = handler.queue();
|
||||
let _ = queue.resume();
|
||||
|
||||
check_msg(
|
||||
msg.channel_id
|
||||
.say(
|
||||
&ctx.http,
|
||||
format!("Song resumed."),
|
||||
)
|
||||
.await,
|
||||
);
|
||||
} else {
|
||||
check_msg(
|
||||
msg.channel_id
|
||||
.say(&ctx.http, "Not in a voice channel to play in")
|
||||
.await,
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -16,18 +16,10 @@ async fn stop(ctx: &Context, msg: &Message) -> CommandResult {
|
||||
.clone();
|
||||
|
||||
if let Some(handler_lock) = manager.get(guild_id) {
|
||||
let mut handler = handler_lock.lock().await;
|
||||
let handler = handler_lock.lock().await;
|
||||
let queue = handler.queue();
|
||||
queue.stop();
|
||||
|
||||
if let Err(e) = handler.deafen(false).await {
|
||||
check_msg(
|
||||
msg.channel_id
|
||||
.say(&ctx.http, format!("Failed: {:?}", e))
|
||||
.await,
|
||||
);
|
||||
}
|
||||
|
||||
check_msg(msg.channel_id.say(&ctx.http, "Playback stopped!").await);
|
||||
} else {
|
||||
check_msg(
|
||||
|
||||
@@ -30,6 +30,9 @@ use crate::commands::music::play::*;
|
||||
use crate::commands::music::queue::*;
|
||||
use crate::commands::music::skip::*;
|
||||
use crate::commands::music::stop::*;
|
||||
use crate::commands::music::loopcurrent::*;
|
||||
use crate::commands::music::pause::*;
|
||||
use crate::commands::music::resume::*;
|
||||
|
||||
// tools
|
||||
use crate::commands::tools::ping::*;
|
||||
@@ -59,7 +62,7 @@ async fn before(_: &Context, msg: &Message, command_name: &str) -> bool {
|
||||
|
||||
#[group]
|
||||
#[commands(
|
||||
join, deafen, leave, mute, play, ping, kashi, queue, stop, skip
|
||||
join, deafen, leave, mute, play, ping, kashi, queue, stop, skip, loopcurrent, pause, resume
|
||||
)]
|
||||
struct General;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user