split main.rs into files

This commit is contained in:
2024-02-16 14:23:20 +01:00
parent eacf4fffae
commit 8a8a807547
14 changed files with 477 additions and 276 deletions

29
src/commands/stop.rs Normal file
View File

@@ -0,0 +1,29 @@
use crate::state::State;
use std::error::Error;
use twilight_model::channel::Message;
pub(crate) async fn stop(
msg: Message,
state: State,
) -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
tracing::debug!(
"stop command in channel {} by {}",
msg.channel_id,
msg.author.name
);
let guild_id = msg.guild_id.unwrap();
if let Some(call_lock) = state.songbird.get(guild_id) {
let call = call_lock.lock().await;
call.queue().stop();
}
state
.http
.create_message(msg.channel_id)
.content("Stopped the track and cleared the queue")?
.await?;
Ok(())
}