Changing bot commands to be used by endpoints

This commit is contained in:
Benjamin Sherriff
2023-10-06 23:34:25 -04:00
parent cb1fd182f1
commit 3ca91c7765
11 changed files with 133 additions and 125 deletions

View File

@@ -3,19 +3,18 @@ extern crate diesel;
extern crate diesel_migrations;
use std::env;
use std::collections::{HashSet, HashMap};
use std::collections::HashSet;
use std::sync::Arc;
use bot::commands::audio::AudioConfig;
use log::{error, warn, info};
use serenity::client::Cache;
use serenity::framework::StandardFramework;
use serenity::http::Http;
use serenity::model::prelude::GuildId;
use serenity::prelude::*;
use songbird::{SerenityInit, Songbird};
use actix_cors::Cors;
use actix_web::{HttpServer, App, web};
use crate::bot::{commands::{oai::GPTModel, audio::AudioConfigs}, handler::Handler};
use crate::bot::{commands::oai::GPTModel, handler::Handler};
use dotenv::dotenv;
@@ -74,35 +73,23 @@ async fn main() -> std::io::Result<()> {
}
};
// let songbird = Songbird::serenity_from_config(songbird::Config::default().decode_mode(songbird::driver::DecodeMode::Decode));
let songbird = Songbird::serenity();
let mut client = Client::builder(token, intents)
.event_handler(handler)
.framework(StandardFramework::new()
.configure(|c| c.owners(owners)))
// .register_songbird_with(Arc::clone(&songbird))
// .register_songbird_from_config(songbird::Config::default().decode_mode(songbird::driver::DecodeMode::Decode))
.register_songbird()
.await
.expect("Error creating client");
let audio_configs: Arc<RwLock<HashMap<GuildId, AudioConfig>>> = Arc::new(RwLock::new(HashMap::default()));
{
let mut data = client.data.write().await;
data.insert::<AudioConfigs>(Arc::clone(&audio_configs));
}
let http = Arc::clone(&client.cache_and_http.http);
// let cache_http = Arc::clone(&client.cache_and_http.clone());
// let data = Arc::clone(&client.data.clone());
// let t = songbird::Config::default().decode_mode(songbird::driver::DecodeMode::Decode);
let cache = Arc::clone(&client.cache_and_http.cache);
let app_data = Arc::new(AppState {
http,
songbird: Arc::clone(&songbird),
audio_configs
cache,
songbird: Arc::clone(&songbird)
});
@@ -153,6 +140,6 @@ async fn main() -> std::io::Result<()> {
pub struct AppState {
pub http: Arc<Http>,
pub songbird: Arc<Songbird>,
pub audio_configs: Arc<RwLock<HashMap<GuildId, AudioConfig>>>
pub cache: Arc<Cache>,
pub songbird: Arc<Songbird>
}