Skip to content

Commit

Permalink
Fix more runtime panics
Browse files Browse the repository at this point in the history
  • Loading branch information
tazz4843 committed Feb 2, 2024
1 parent a557e2a commit 98067d8
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{sync::Arc, time::Duration};
use scripty_metrics::Metrics;
use serenity::{client::Context, model::id::ChannelId};

use crate::{background_tasks::core::BackgroundTask, Error};
use crate::{background_tasks::core::BackgroundTask, Data, Error};

/// Updates Prometheus latency metrics every 10 seconds.
pub struct LatencyUpdater(Arc<Metrics>, Context);
Expand All @@ -19,8 +19,12 @@ impl BackgroundTask for LatencyUpdater {
}

async fn run(&mut self) {
let ctx_data = self.1.data::<Data>();
let Some(shard_manager) = ctx_data.shard_manager.get() else {
return;
};
self.0.latency.websocket.set(
scripty_utils::latency::get_ws_latency(&self.1.data(), self.1.shard_id.0)
scripty_utils::latency::get_ws_latency(&shard_manager, self.1.shard_id.0)

Check warning on line 27 in scripty_bot_utils/src/background_tasks/tasks/prometheus_latency_update.rs

View workflow job for this annotation

GitHub Actions / Clippy Output

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> scripty_bot_utils/src/background_tasks/tasks/prometheus_latency_update.rs:27:43 | 27 | scripty_utils::latency::get_ws_latency(&shard_manager, self.1.shard_id.0) | ^^^^^^^^^^^^^^ help: change this to: `shard_manager` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default
.await
.unwrap_or(0) as i64,
);
Expand Down

0 comments on commit 98067d8

Please sign in to comment.