Reserve sound names beginning with '@'
Might want to use this in the future. Remove the /random command as it's dumb.
This commit is contained in:
parent
6d324e10cb
commit
d3e00247bd
@ -35,7 +35,13 @@ pub async fn upload_new_sound(
|
||||
}
|
||||
|
||||
if !name.is_empty() && name.len() <= 20 {
|
||||
if !is_numeric(&name) {
|
||||
if name.starts_with("@") {
|
||||
ctx.say("Sound names cannot start with an @ symbol. Please choose another name")
|
||||
.await?;
|
||||
} else if is_numeric(&name) {
|
||||
ctx.say("Please ensure the sound name contains a non-numerical character")
|
||||
.await?;
|
||||
} else {
|
||||
// need to check the name is not currently in use by the user
|
||||
let count_name =
|
||||
Sound::count_named_user_sounds(ctx.author().id, &name, &ctx.data().database)
|
||||
@ -50,7 +56,7 @@ pub async fn upload_new_sound(
|
||||
let count = Sound::count_user_sounds(ctx.author().id, &ctx.data().database).await?;
|
||||
let mut permit_upload = true;
|
||||
|
||||
// need to check if user is patreon or nah
|
||||
// need to check if user is Patreon or not
|
||||
if count >= *MAX_SOUNDS {
|
||||
let patreon_guild_member =
|
||||
GuildId(*PATREON_GUILD).member(ctx, ctx.author().id).await;
|
||||
@ -88,9 +94,6 @@ pub async fn upload_new_sound(
|
||||
)).await?;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ctx.say("Please ensure the sound name contains a non-numerical character")
|
||||
.await?;
|
||||
}
|
||||
} else {
|
||||
ctx.say("Usage: `/upload <name>`. Please ensure the name provided is less than 20 characters in length").await?;
|
||||
|
@ -292,28 +292,3 @@ pub async fn search_sounds(
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Show a page of random sounds
|
||||
#[poise::command(slash_command, rename = "random", guild_only = true)]
|
||||
pub async fn show_random_sounds(ctx: Context<'_>) -> Result<(), Error> {
|
||||
let search_results = sqlx::query_as_unchecked!(
|
||||
Sound,
|
||||
"
|
||||
SELECT name, id, public, server_id, uploader_id
|
||||
FROM sounds
|
||||
WHERE public = 1
|
||||
ORDER BY rand()
|
||||
LIMIT 25
|
||||
"
|
||||
)
|
||||
.fetch_all(&ctx.data().database)
|
||||
.await?;
|
||||
|
||||
ctx.send(|m| {
|
||||
*m = format_search_results(search_results);
|
||||
m
|
||||
})
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user