Skip to content

Commit c74d5ef

Browse files
committed
Fix some deprecated methods
1 parent 89ebb3d commit c74d5ef

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

crates/robbb/src/events/message_update.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ pub async fn message_update(
2323
.unwrap_or_else(|| "<Unavailable>".to_string());
2424

2525
if let Some(new) = new {
26+
let channel_name =
27+
new.channel_id.name(ctx).await.unwrap_or_else(|_| "unknown-name".to_string());
2628
tracing::info!(
2729
msg.id = %event.id,
2830
msg.author = %new.author.tag(),
2931
msg.author_id = %new.author.id,
30-
msg.channel = %new.channel_id.name_cached_or_fallback(&ctx.cache),
32+
msg.channel = %channel_name,
3133
msg.channel_id = %new.channel_id,
3234
msg.content = %new.content,
3335
msg.old_content = %old_content,

crates/robbb/src/events/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,14 @@ impl client::EventHandler for Handler {
119119
fields(
120120
command_name, invocation, message_create.notified_user_cnt, message_create.emoji_used,
121121
%msg.content, msg.author = %msg.author.tag(), %msg.channel_id, %msg.id,
122-
msg.channel = %msg.channel_id.name_cached_or_fallback(&ctx.cache),
122+
msg.channel
123123
)
124124
)]
125125
async fn message(&self, ctx: client::Context, msg: Message) {
126+
let channel_name =
127+
msg.channel_id.name(&ctx).await.unwrap_or_else(|_| "unknown-name".to_string());
128+
tracing::Span::current().record("msg.channel", channel_name);
129+
126130
match message_create::message_create(ctx.clone(), msg.clone()).await {
127131
Ok(stop_event_handler) if stop_event_handler => return,
128132
err => log_error!("Error handling message_create event", err),

crates/robbb/src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use pyroscope_pprofrs::{pprof_backend, PprofConfig};
77
use robbb_commands::{checks, commands};
88
use robbb_db::Db;
99

10-
use robbb_util::{config::Config, extensions::ChannelIdExt, prelude::Ctx, UserData};
10+
use robbb_util::{config::Config, prelude::Ctx, UserData};
1111
use serenity::all::OnlineStatus;
1212
use std::sync::Arc;
1313

@@ -147,7 +147,8 @@ async fn pre_command(ctx: Ctx<'_>) {
147147
poise::Context::Application(_) => ctx.invocation_string(),
148148
poise::Context::Prefix(prefix) => prefix.msg.content.to_string(),
149149
};
150-
let channel_name = ctx.channel_id().name_cached_or_fallback(&ctx.cache());
150+
let channel_name =
151+
ctx.channel_id().name(ctx).await.unwrap_or_else(|_| "unknown-name".to_string());
151152

152153
let span = tracing::Span::current();
153154
span.record("command_name", ctx.command().qualified_name.as_str());

crates/robbb_util/src/extensions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use serenity::{
1010
CreateAllowedMentions, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, CreateMessage,
1111
CreateThread,
1212
},
13-
client::{self, Cache},
13+
client::{self},
1414
model::{
1515
channel::{GuildChannel, Message},
1616
guild::Emoji,

0 commit comments

Comments
 (0)