Change macro list to use fields to prevent going over limit

Add length checks for name and description
This commit is contained in:
2022-09-17 12:37:58 +01:00
parent b62d24c024
commit 57336f5c81
4 changed files with 42 additions and 66 deletions

View File

@ -15,6 +15,18 @@ pub async fn record_macro(
#[description = "Name for the new macro"] name: String,
#[description = "Description for the new macro"] description: Option<String>,
) -> Result<(), Error> {
if name.len() > 100 {
ctx.say("Name must be less than 100 characters").await?;
return Ok(());
}
if description.as_ref().map_or(0, |d| d.len()) > 100 {
ctx.say("Description must be less than 100 characters").await?;
return Ok(());
}
let guild_id = ctx.guild_id().unwrap();
let row = sqlx::query!(