Add hidden feature to not send messages when they're preceeded by an X

This commit is contained in:
2025-08-24 03:51:08 -03:00
parent bd09a55a74
commit 497d180669
4 changed files with 37 additions and 10 deletions
+13 -4
View File
@@ -1,3 +1,5 @@
use std::collections::HashSet;
use scylla::{
DeserializeValue, SerializeValue,
client::session::Session,
@@ -102,6 +104,7 @@ pub struct User {
pub supporter_since: Option<UtcDateTime>,
pub supporter_until: Option<UtcDateTime>,
pub is_banned_from_leaderboard: Option<bool>,
pub findings: HashSet<String>,
}
impl<'a> Object<'a> for User {
@@ -116,6 +119,7 @@ impl<'a> Object<'a> for User {
Option<OffsetDateTime>,
Option<OffsetDateTime>,
Option<bool>,
HashSet<String>,
);
fn from_row(row: Self::Row) -> Self {
@@ -130,6 +134,7 @@ impl<'a> Object<'a> for User {
supporter_since: row.7.map(|i| i.into()),
supporter_until: row.8.map(|i| i.into()),
is_banned_from_leaderboard: row.9,
findings: row.10,
}
}
@@ -145,6 +150,7 @@ impl<'a> Object<'a> for User {
value.supporter_since.map(|i| i.into()),
value.supporter_until.map(|i| i.into()),
Some(value.is_banned_from_leaderboard.unwrap_or(false)),
value.findings,
)
}
}
@@ -171,7 +177,8 @@ impl User {
last_seen_at,
supporter_since,
supporter_until,
is_banned_from_leaderboard
is_banned_from_leaderboard,
findings
FROM
payphone.users
WHERE
@@ -208,7 +215,7 @@ impl User {
/// Returns:
/// [`Result<User, DatabaseError>`] - The user from the database or a new user created from
/// Discord.
pub async fn get_or_create_and_set_last_seen(
pub async fn create_or_update(
user: TwilightUser,
session: &Session,
) -> Result<Self, DatabaseError> {
@@ -241,8 +248,9 @@ impl User {
last_seen_at,
supporter_since,
supporter_until,
is_banned_from_leaderboard
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
is_banned_from_leaderboard,
findings
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
"#,
Self::to_row(self.clone()),
)
@@ -329,6 +337,7 @@ impl From<TwilightUser> for User {
supporter_since: None,
supporter_until: None,
is_banned_from_leaderboard: None,
findings: HashSet::new(),
}
}
}