Placeholder while updating query
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use serenity::all::{
|
||||
CommandInteraction, Context, CreateInteractionResponse, CreateInteractionResponseMessage,
|
||||
CreateMessage, EditInteractionResponse, InteractionResponseFlags, Message, ModalInteraction,
|
||||
User, UserId,
|
||||
UserId,
|
||||
};
|
||||
|
||||
pub async fn process_message(ctx: &Context, command: &CommandInteraction, private: bool) {
|
||||
|
||||
@@ -7,6 +7,7 @@ use serenity::all::{
|
||||
};
|
||||
|
||||
use crate::bot::chat::{create_message_response, edit_response};
|
||||
use crate::error::{Error, SirenResult};
|
||||
use crate::utils::{a_or_an, number_to_words};
|
||||
|
||||
pub async fn run(ctx: &Context, command: &CommandInteraction) {
|
||||
@@ -64,6 +65,8 @@ pub async fn run(ctx: &Context, command: &CommandInteraction) {
|
||||
}
|
||||
None => edit_response(&ctx, &command, format!("🎲 {}\n-# {}", total, response)).await,
|
||||
};
|
||||
// Check for dice tracks
|
||||
|
||||
}
|
||||
Err(why) => {
|
||||
edit_response(&ctx, &command, format!("Invalid dice string: {}", why)).await;
|
||||
@@ -123,7 +126,7 @@ pub fn roll_dice(count: u32, sides: u32, modifier: i32) -> i32 {
|
||||
total
|
||||
}
|
||||
|
||||
pub fn parse_dice(dice: &str) -> Result<(u32, u32, i32), String> {
|
||||
pub fn parse_dice(dice: &str) -> SirenResult<(u32, u32, i32)> {
|
||||
// If the input is just a number (e.g., "20" or "6"), assume it's the number of sides
|
||||
if let Ok(n) = dice.parse::<u32>() {
|
||||
return Ok((1, n, 0)); // Assume 1 dice with 0 modifiers
|
||||
@@ -144,31 +147,31 @@ pub fn parse_dice(dice: &str) -> Result<(u32, u32, i32), String> {
|
||||
Some("") => 1, // Handle cases like "d6", assume 1 dice
|
||||
Some(c) => match c.parse::<u32>() {
|
||||
Ok(n) => n,
|
||||
Err(_) => return Err(format!("Invalid dice count: {}", c)),
|
||||
Err(_) => return Err(Error::new(400, format!("Invalid dice count: {}", c))),
|
||||
},
|
||||
None => return Err(format!("Invalid dice string: {}", dice)),
|
||||
None => return Err(Error::new(400, format!("Invalid dice string: {}", dice))),
|
||||
};
|
||||
|
||||
// Parse the number of sides
|
||||
let sides_part = parts
|
||||
.next()
|
||||
.ok_or_else(|| format!("Invalid dice string: {}", dice))?;
|
||||
.ok_or_else(|| Error::new(400, format!("Invalid dice string: {}", dice)))?;
|
||||
let sides = match sides_part.parse::<u32>() {
|
||||
Ok(n) => {
|
||||
if [4, 6, 8, 10, 12, 20, 100].contains(&n) {
|
||||
n
|
||||
} else {
|
||||
return Err(format!(
|
||||
return Err(Error::new(400, format!(
|
||||
"Expected one of d4, d6, d8, d10, d12, d20, d100 but received d{}",
|
||||
n
|
||||
));
|
||||
)));
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
return Err(format!(
|
||||
return Err(Error::new(400, format!(
|
||||
"Expected one of d4, d6, d8, d10, d12, d20, d100 but received d{}",
|
||||
sides_part
|
||||
))
|
||||
)))
|
||||
}
|
||||
};
|
||||
|
||||
@@ -189,7 +192,7 @@ pub fn parse_dice(dice: &str) -> Result<(u32, u32, i32), String> {
|
||||
-n
|
||||
}
|
||||
}
|
||||
Err(_) => return Err(format!("Invalid dice modifier: {}", m)),
|
||||
Err(_) => return Err(Error::new(400, format!("Invalid dice modifier: {}", m))),
|
||||
},
|
||||
None => 0, // No modifier found
|
||||
};
|
||||
|
||||
@@ -23,6 +23,7 @@ pub struct BotHandler {
|
||||
pub oai: Option<OAI>,
|
||||
}
|
||||
|
||||
static REGISTERED: OnceLock<bool> = OnceLock::new();
|
||||
static SONGBIRD: OnceLock<Arc<Songbird>> = OnceLock::new();
|
||||
static CLIENT: OnceLock<reqwest::Client> = OnceLock::new();
|
||||
|
||||
@@ -104,6 +105,13 @@ impl EventHandler for BotHandler {
|
||||
CLIENT.set(http_client).ok();
|
||||
}
|
||||
|
||||
// Update registered to prevent reloading the commands
|
||||
if REGISTERED.get().is_some() {
|
||||
return;
|
||||
} else {
|
||||
REGISTERED.set(true).ok();
|
||||
}
|
||||
|
||||
log::trace!("Handling {} guilds", ready.guilds.len());
|
||||
for guild in ready.guilds {
|
||||
// Check if guild exists in database
|
||||
|
||||
Reference in New Issue
Block a user