Add colors update

This commit is contained in:
2025-08-24 20:03:52 -03:00
parent 39120a65fa
commit 3f5ec4f258
13 changed files with 1304 additions and 50 deletions
+18 -11
View File
@@ -105,7 +105,7 @@ use std::{
net::{IpAddr, Ipv4Addr, SocketAddr},
path::Path,
process::Command,
sync::mpsc,
sync::Arc,
};
use async_trait::async_trait;
@@ -126,7 +126,8 @@ use twilight_model::{
use crate::{
cli::{Args, Commands},
constants::DEFAULT_PREFIX,
colors::init_color_fetching_queue_listener,
constants::{DEFAULT_PREFIX, VERSION},
database::models::{Server, User},
extras::Extras,
framework::{
@@ -137,7 +138,9 @@ use crate::{
groups::{
about::{commands::HelpCommand, components::HelpGoBackButton},
calls::{
commands::{CallCommand, FriendRequestCommand, HangupCommand, MaskCommand, SkipCommand},
commands::{
CallCommand, FriendRequestCommand, HangupCommand, MaskCommand, SkipCommand,
},
events::{CallMessageDeleteHandler, CallMessageEditHandler, CallMessageHandler},
},
gateway::events::{ReadyHandler, ReconnectHandler},
@@ -152,6 +155,7 @@ use crate::{
};
mod cli;
mod colors;
mod constants;
mod database;
mod discord;
@@ -241,7 +245,8 @@ impl ExtrasGetter<State> for PayphoneExtrasGetter {
) -> Result<Self::Extras, Box<dyn Error>> {
log::trace!("Getting extras!");
let user = User::create_or_update(user.clone(), &rt.state.db).await?;
let user = User::create_or_update(user.clone(), &rt.state.db, &rt.state.color_queue_sender)
.await?;
Ok(Extras { user })
}
@@ -258,10 +263,7 @@ async fn start(
bot_owner_id: u64,
) {
log::info!("Welcome to Payphone, Nyeki!");
log::info!(
"Payphone is running on version v{}",
env!("CARGO_PKG_VERSION")
);
log::info!("Payphone is running on version v{VERSION}");
let db = database::init(database_addr, database_username, database_password)
.await
@@ -273,11 +275,16 @@ async fn start(
log::info!("Redis connection established successfully.");
let state = State {
let (color_queue_sender, color_queue_receiver) = tokio::sync::mpsc::channel(100);
let state = Arc::new(State {
db,
redis: redis_pool,
bot_owner_id,
};
color_queue_sender,
});
init_color_fetching_queue_listener(color_queue_receiver, state.clone());
let bot = Bot::new(state, ServerPrefixOrPayphoneMention, PayphoneExtrasGetter)
.shard(shard)
@@ -352,7 +359,7 @@ async fn docs(bind: SocketAddr, open_on_start: bool) {
.expect("Failed to run `cargo doc`");
tokio::spawn(async {
let (tx, rx) = mpsc::channel::<notify::Result<Event>>();
let (tx, rx) = std::sync::mpsc::channel::<notify::Result<Event>>();
let mut watcher = notify::recommended_watcher(tx).expect("Failed to create watcher");