This is the Rust version of the discord bot created for FBT Heaven
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Update and fix some warnings

Mainly just changing old deprecated functions to their newer counterparts

+23 -21
+7 -6
src/commands/database.rs
··· 187 187 ctx: Context<'_>, 188 188 #[description = "Member to search for. This must be a user ID."] user_id: String, 189 189 ) -> Result<(), Error> { 190 + use chrono::DateTime; 190 191 use pastemyst::paste::*; 191 192 use pastemyst::str; 192 193 use poise::serenity_prelude::User; ··· 381 382 382 383 #[allow(clippy::cast_possible_truncation)] 383 384 // this shouldn't be able to break but just in case I'm making the `unwrap_or` output NaiveDateTime::MIN 384 - let date_time_stamp = chrono::NaiveDateTime::from_timestamp_opt(unix_timecode as i64, 0) 385 - .unwrap_or(chrono::NaiveDateTime::MIN); 385 + let date_time_stamp = DateTime::from_timestamp(unix_timecode as i64, 0).unwrap_or(DateTime::UNIX_EPOCH); 386 386 387 387 let age = chrono::Utc::now() 388 388 .naive_utc() 389 - .signed_duration_since(date_time_stamp) 389 + .signed_duration_since(date_time_stamp.naive_local()) 390 390 .num_days(); 391 391 392 392 let is_user_in_db: Option<String> = check_username_against_db(ctx.author().id.0).await.unwrap(); ··· 626 626 BlacklistOutput, 627 627 >, 628 628 ) -> Result<(), Error> { 629 + use chrono::DateTime; 630 + 629 631 ctx.defer().await?; 630 632 631 633 let mut con = open_redis_connection().await?; ··· 929 931 930 932 #[allow(clippy::cast_possible_truncation)] 931 933 // this shouldn't be able to break but just in case I'm making the `unwrap_or` output NaiveDateTime::MIN 932 - let date_time_stamp = chrono::NaiveDateTime::from_timestamp_opt(unix_timecode as i64, 0) 933 - .unwrap_or(chrono::NaiveDateTime::MIN); 934 + let date_time_stamp = DateTime::from_timestamp(unix_timecode as i64, 0).unwrap_or(DateTime::UNIX_EPOCH); 934 935 935 936 let age = chrono::Utc::now() 936 937 .naive_utc() 937 - .signed_duration_since(date_time_stamp) 938 + .signed_duration_since(date_time_stamp.naive_local()) 938 939 .num_days(); 939 940 940 941 let is_user_in_db: Option<String> =
+6 -6
src/commands/tools.rs
··· 1 - use chrono::NaiveDateTime; 1 + use chrono::DateTime; 2 2 use poise::serenity_prelude::{self as serenity, AttachmentType, RichInvite}; 3 3 use rusted_fbt_lib::{ 4 4 checks::guild_auth_check, ··· 26 26 #[allow(clippy::cast_possible_truncation)] 27 27 // this shouldn't be able to break but just in case I'm making the `unwrap_or` output NaiveDateTime::MIN 28 28 let date_time_stamp = 29 - NaiveDateTime::from_timestamp_opt(unix_timecode as i64, 0).unwrap_or(NaiveDateTime::MIN); 29 + DateTime::from_timestamp(unix_timecode as i64, 0).unwrap_or(DateTime::UNIX_EPOCH); 30 30 31 31 let age = chrono::Utc::now() 32 32 .naive_utc() 33 - .signed_duration_since(date_time_stamp) 33 + .signed_duration_since(date_time_stamp.naive_local()) 34 34 .num_days(); 35 35 36 36 ctx.say(format!( ··· 56 56 #[allow(clippy::cast_possible_truncation)] 57 57 // this shouldn't be able to break but just in case I'm making the `unwrap_or` output NaiveDateTime::MIN 58 58 let date_time_stamp = 59 - NaiveDateTime::from_timestamp_opt(unix_timecode as i64, 0).unwrap_or(NaiveDateTime::MIN); 59 + DateTime::from_timestamp(unix_timecode as i64, 0).unwrap_or(DateTime::UNIX_EPOCH); 60 60 61 61 ctx.say(format!("Created/Joined on {date_time_stamp}")) 62 62 .await?; ··· 277 277 #[allow(clippy::cast_possible_truncation)] 278 278 // this shouldn't be able to break but just in case I'm making the `unwrap_or` output NaiveDateTime::MIN 279 279 let date_time_stamp = 280 - NaiveDateTime::from_timestamp_opt(unix_timecode as i64, 0).unwrap_or(NaiveDateTime::MIN); 280 + DateTime::from_timestamp(unix_timecode as i64, 0).unwrap_or(DateTime::UNIX_EPOCH); 281 281 282 282 let age = chrono::Utc::now() 283 283 .naive_utc() 284 - .signed_duration_since(date_time_stamp) 284 + .signed_duration_since(date_time_stamp.naive_local()) 285 285 .num_days(); 286 286 287 287 let is_user_in_db: Option<String> =
+5 -4
src/lib/event_handlers.rs
··· 1 1 use crate::structs::{GuildSettings, UserInfo, WaybackResponse, WaybackStatus}; 2 2 use crate::utils::snowflake_to_unix; 3 3 use crate::vars::FBT_GUILD_ID; 4 - use chrono::NaiveDateTime; 4 + // use chrono::NaiveDateTime; 5 5 use chrono::Utc; 6 6 use chrono_tz::Australia::Melbourne; 7 7 use colored::Colorize; ··· 90 90 ctx: &serenity::Context, 91 91 member: &serenity::Member, 92 92 ) -> Result<(), Box<dyn std::error::Error + Send + Sync>> { 93 + use chrono::DateTime; 94 + 93 95 use crate::utils::open_redis_connection; 94 96 use std::collections::HashSet; 95 97 ··· 133 135 134 136 #[allow(clippy::pedantic)] 135 137 // it literally only take's i64, no need to warn about truncation here. 136 - let date_time_stamp = NaiveDateTime::from_timestamp_opt(unix_timecode as i64, 0) 137 - .unwrap_or(NaiveDateTime::MIN); 138 + let date_time_stamp = DateTime::from_timestamp(unix_timecode as i64, 0).unwrap_or(DateTime::UNIX_EPOCH); 138 139 139 140 let age = chrono::Utc::now() 140 141 .naive_utc() 141 - .signed_duration_since(date_time_stamp) 142 + .signed_duration_since(date_time_stamp.naive_local()) 142 143 .num_days(); 143 144 144 145 // Compare user age
+1 -1
src/lib/memes.rs
··· 36 36 let mut hits: Vec<&str> = Vec::new(); 37 37 38 38 for word in words { 39 - POG_RE.find(word).map_or((), |pog| { 39 + let _ = POG_RE.find(word).map_or((), |pog| { 40 40 hits.push(pog.as_str()); 41 41 }); 42 42 }
+4 -4
src/lib/utils.rs
··· 25 25 /// Open a tokio redis connection 26 26 #[cfg(feature = "database")] 27 27 #[instrument()] 28 - pub async fn open_redis_connection() -> Result<redis::aio::Connection, anyhow::Error> { 28 + pub async fn open_redis_connection() -> Result<redis::aio::MultiplexedConnection, anyhow::Error> { 29 29 let redis_connection = redis::Client::open(REDIS_ADDR)? 30 - .get_tokio_connection() 30 + .get_multiplexed_tokio_connection() 31 31 .await?; 32 32 33 33 Ok(redis_connection) ··· 38 38 #[instrument(skip(con))] 39 39 pub async fn set_guild_settings( 40 40 ctx: Context<'_>, 41 - con: &mut redis::aio::Connection, 41 + con: &mut redis::aio::MultiplexedConnection, 42 42 settings: GuildSettings, 43 43 ) -> Result<(), Error> { 44 44 let json = serde_json::to_string(&settings).unwrap(); ··· 64 64 #[instrument(skip(con))] 65 65 pub async fn auth( 66 66 ctx: Context<'_>, 67 - con: &mut redis::aio::Connection, 67 + con: &mut redis::aio::MultiplexedConnection, 68 68 uid: String, 69 69 ) -> Result<(), Error> { 70 70 redis::cmd("SADD")