format and restructure, began working on schedule
This commit is contained in:
@@ -5,7 +5,7 @@ use serenity::model::gateway::Ready;
|
||||
use serenity::model::channel::Message;
|
||||
use serenity::prelude::*;
|
||||
|
||||
use super::guilds::GuildCache;
|
||||
use crate::database::guilds::GuildCache;
|
||||
use super::{commands, oai};
|
||||
use super::commands::audio::create_response;
|
||||
|
||||
@@ -26,15 +26,10 @@ impl EventHandler for Handler {
|
||||
match msg.mentions_me(&ctx.http).await {
|
||||
Ok(mentioned) => {
|
||||
let bot_in_thread = match msg.channel_id.get_thread_members(&ctx.http).await {
|
||||
Ok(t) => {
|
||||
match t
|
||||
.iter()
|
||||
.find(|t| t.user_id == ctx.cache.current_user().id)
|
||||
{
|
||||
Some(_) => true,
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
Ok(t) => match t.iter().find(|t| t.user_id == ctx.cache.current_user().id) {
|
||||
Some(_) => true,
|
||||
None => false,
|
||||
},
|
||||
Err(_) => false,
|
||||
};
|
||||
if mentioned || bot_in_thread {
|
||||
@@ -53,17 +48,18 @@ impl EventHandler for Handler {
|
||||
log::trace!("Received command interaction: {command:#?}");
|
||||
match command.data.name.as_str() {
|
||||
// Match commands without returns
|
||||
"roll" => commands::roll::run(&ctx, &command).await,
|
||||
"play" => commands::audio::play::run(&ctx, &command).await,
|
||||
"stop" => commands::audio::stop::run(&ctx, &command).await,
|
||||
"pause" => commands::audio::pause::run(&ctx, &command).await,
|
||||
"resume" => commands::audio::resume::run(&ctx, &command).await,
|
||||
"skip" => commands::audio::skip::run(&ctx, &command).await,
|
||||
"volume" => commands::audio::volume::run(&ctx, &command).await,
|
||||
"schedule" => commands::event::schedule::run(&ctx, &command).await,
|
||||
"roll" => commands::fun::roll::run(&ctx, &command).await,
|
||||
_ => {
|
||||
let content: String = match command.data.name.as_str() {
|
||||
// Match commands with string returns
|
||||
"ping" => commands::ping::run(&command.data.options),
|
||||
"ping" => commands::utility::ping::run(&command.data.options),
|
||||
_ => "Unknown command".to_string(),
|
||||
};
|
||||
create_response(&ctx, &command, content).await;
|
||||
@@ -83,28 +79,37 @@ impl EventHandler for Handler {
|
||||
let guild_cache = GuildCache {
|
||||
id: guild_id,
|
||||
bot_id: 1,
|
||||
volume: 100
|
||||
volume: 100,
|
||||
};
|
||||
guild_cache.insert().await.unwrap();
|
||||
}
|
||||
let commands = guild
|
||||
.id
|
||||
.set_commands(&ctx.http, vec![
|
||||
commands::ping::register(),
|
||||
commands::roll::register(),
|
||||
commands::audio::play::register(),
|
||||
commands::audio::stop::register(),
|
||||
commands::audio::pause::register(),
|
||||
commands::audio::resume::register(),
|
||||
commands::audio::skip::register(),
|
||||
commands::audio::volume::register(),
|
||||
])
|
||||
.set_commands(
|
||||
&ctx.http,
|
||||
vec![
|
||||
commands::audio::play::register(),
|
||||
commands::audio::stop::register(),
|
||||
commands::audio::pause::register(),
|
||||
commands::audio::resume::register(),
|
||||
commands::audio::skip::register(),
|
||||
commands::audio::volume::register(),
|
||||
commands::event::schedule::register(),
|
||||
commands::fun::roll::register(),
|
||||
commands::utility::ping::register(),
|
||||
],
|
||||
)
|
||||
.await;
|
||||
match commands {
|
||||
Ok(c) => info!("Registered {} commands for guild {}", c.len(), guild.id.get()),
|
||||
Ok(c) => info!(
|
||||
"Registered {} commands for guild {}",
|
||||
c.len(),
|
||||
guild.id.get()
|
||||
),
|
||||
Err(why) => error!(
|
||||
"Could not register commands for guild {}: {:?}",
|
||||
guild.id.get(), why
|
||||
guild.id.get(),
|
||||
why
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user