Removed audio gitignore

This commit is contained in:
2024-11-03 11:52:24 -05:00
parent 8ea9c8d711
commit 806f2dcd50
7 changed files with 92 additions and 12 deletions

5
src/api/mod.rs Normal file
View File

@@ -0,0 +1,5 @@
use axum::Router;
pub fn get_routes() -> Router {
Router::new()
}

View File

@@ -0,0 +1,52 @@
use serenity::{
all::{CommandInteraction, CreateCommand},
prelude::*,
};
use super::{edit_response, get_songbird, process_message};
pub async fn run(ctx: &Context, command: &CommandInteraction) {
// Create the initial response
process_message(&ctx, &command).await;
// Get the songbird manager
let manager = get_songbird(ctx).await;
// Extract the guild ID
let guild_id = match &command.guild_id {
Some(guild_id) => guild_id,
None => {
edit_response(
&ctx,
&command,
"Unable to find the current server ID".to_string(),
)
.await;
return;
}
};
// Mute the track
if let Some(handler_lock) = manager.get(guild_id.to_owned()) {
let mut handler = handler_lock.lock().await;
let is_muted = handler.is_mute();
match handler.mute(!is_muted).await {
Ok(_) => {
if is_muted {
log::debug!("<{guild_id}> Unmuted");
edit_response(&ctx, &command, format!("Unmuted")).await;
} else {
log::debug!("<{guild_id}> Muted");
edit_response(&ctx, &command, format!("Muted")).await;
}
}
Err(err) => {
edit_response(&ctx, &command, format!("Failed to mute: {}", err)).await;
}
}
}
}
pub fn register() -> CreateCommand {
CreateCommand::new("mute").description("Mute/unmute Siren")
}

View File

@@ -1,13 +1,16 @@
use std::env;
use std::collections::HashSet;
use std::sync::Arc;
use axum::Router;
use serenity::http::Http;
use serenity::prelude::*;
use songbird::{SerenityInit, Songbird};
use reqwest::Client as HttpClient;
use tokio::net::TcpListener;
use crate::bot::handler::Handler;
mod api;
mod bot;
mod data;
mod error;
@@ -27,6 +30,23 @@ async fn main() {
return;
};
// Start API server
tokio::spawn(async move {
start_api().await;
});
// Start Discord bot
// start_bot().await;
}
async fn start_api() {
let app = Router::new();
let listener = TcpListener::bind("127.0.0.1:3000").await.unwrap();
log::debug!("listening on {}", listener.local_addr().unwrap());
axum::serve(listener, app).await.unwrap();
}
async fn start_bot() {
let token: String = env::var("DISCORD_TOKEN").expect("Expected a token in the environment");
let intents: GatewayIntents = GatewayIntents::all();
@@ -86,7 +106,7 @@ async fn main() {
shard_manager.shutdown_all().await;
});
// Start listening for events by starting a single shard
// Start Discord bot
if let Err(why) = client.start_autosharded().await {
log::error!("Client error: {why:?}");
}