cache
All checks were successful
Build / Build (push) Successful in 1m49s
Build / docker (push) Successful in 19s

This commit is contained in:
파링 2026-01-07 20:29:29 +09:00
parent e934da887f
commit 11f6f1edbf
Signed by: paring
SSH key fingerprint: SHA256:8uCHhCpn/gVOLEaTolmbub9kfM6XBxWkIWmHxUZoWWk
4 changed files with 26 additions and 3 deletions

View file

@ -205,6 +205,11 @@ impl Handler {
return Ok(());
}
debug!(
"cached message: {:?}",
ctx.cache.message(channel_id, message_id).as_deref()
);
let msg = channel_id
.message((ctx.cache(), ctx.http()), message_id)
.await?;
@ -225,6 +230,14 @@ impl Handler {
CloneBuilderMessage::from(msg.clone())
};
debug!(
"cached channel: {:?}",
ctx.cache
.guild(guild_id)
.as_ref()
.and_then(|x| x.channel(channel_id).clone())
);
let channel = channel_id
.to_channel((ctx.cache(), ctx.http()), Some(guild_id))
.await?;
@ -269,6 +282,11 @@ impl Handler {
.parse()
.context("unable to parse counter channel id")?;
debug!(
"cached counter msg: {:?}",
ctx.cache.message(chn_id, msg_id).as_deref()
);
let existing_message = chn_id.message((ctx.cache(), ctx.http()), msg_id).await?;
for comp in existing_message

View file

@ -11,6 +11,7 @@ use secrecy::ExposeSecret;
use serenity::{
Client,
all::{GatewayIntents, Token},
cache,
};
use sqlx::{migrate, postgres::PgPoolOptions};
use tracing::Level;
@ -53,18 +54,21 @@ async fn main() -> anyhow::Result<()> {
info!("migrated database");
let mut cache_settings = cache::Settings::default();
cache_settings.max_messages = 100;
let mut client = Client::builder(
Token::from_str(config.bot.token.expose_secret()).unwrap(),
GatewayIntents::GUILD_MESSAGES
| GatewayIntents::GUILD_MESSAGE_REACTIONS
| GatewayIntents::GUILDS
| GatewayIntents::GUILD_MESSAGES
| GatewayIntents::MESSAGE_CONTENT,
)
.event_handler(Arc::new(Handler {
db,
message_lock: Arc::new(DashMap::new()),
}))
.cache_settings(cache_settings)
.await
.expect("Err creating client");