Skip to content
This repository was archived by the owner on Jun 17, 2025. It is now read-only.

Commit 8cf51d6

Browse files
committed
Fix some Clippy lints
1 parent 300e583 commit 8cf51d6

File tree

42 files changed

+154
-121
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+154
-121
lines changed

scripty_audio_handler/src/audio_handler.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,15 @@ use songbird::{Event, EventContext, EventHandler};
2424

2525
use crate::{
2626
error::Error,
27-
events::*,
27+
events::{
28+
VoiceTickContext,
29+
client_disconnect,
30+
driver_connect,
31+
driver_disconnect,
32+
rtp_packet,
33+
speaking_state_update,
34+
voice_tick,
35+
},
2836
types::{
2937
ActiveUserSet,
3038
NextUserList,
@@ -117,7 +125,7 @@ impl AudioHandler {
117125
context,
118126
premium_level: Arc::new(AtomicU8::new(0)),
119127
verbose: Arc::new(AtomicBool::new(false)),
120-
language: Arc::new(Default::default()),
128+
language: Arc::new(RwLock::new(String::new())),
121129
transcript_results: record_transcriptions.then(|| Arc::new(RwLock::new(Vec::new()))),
122130
seen_users: record_transcriptions
123131
.then(|| Arc::new(DashSet::with_hasher(RandomState::new()))),
@@ -153,7 +161,7 @@ impl AudioHandler {
153161
}
154162
debug!(%guild_id, "got request to reload config for this call");
155163
}
156-
_ = tokio::time::sleep(RELOAD_TIME) => {}
164+
() = tokio::time::sleep(RELOAD_TIME) => {}
157165
}
158166
if let Err(e) = t2.reload_config().await {
159167
error!("failed to reload config: {:?}", e);

scripty_audio_handler/src/disconnect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub async fn disconnect_from_vc(ctx: &Context, guild_id: GuildId) -> Result<bool
1515
Err(e) => Err(e.into()),
1616
};
1717

18-
get_data(ctx).existing_calls.force_remove_guild(&guild_id);
18+
let _ = get_data(ctx).existing_calls.force_remove_guild(&guild_id);
1919

2020
let existing = super::AUTO_LEAVE_TASKS
2121
.get_or_init(|| DashMap::with_hasher(ahash::RandomState::default()))

scripty_audio_handler/src/events/voice_tick.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,8 @@ async fn handle_speakers(ssrc_state: Arc<SsrcMaps>, metrics: Arc<Metrics>, voice
440440
// feed audio to transcription stream
441441
if let Some(stream) = ssrc_state.ssrc_stream_map.get(&ssrc) {
442442
if let Err(e) = stream.feed_audio(audio) {
443-
warn!("failed to feed audio packet: {}", e)
444-
};
443+
warn!("failed to feed audio packet: {}", e);
444+
}
445445
trace!(?ssrc, "done processing pkt");
446446
} else {
447447
warn!(?ssrc, "no stream found for ssrc");
@@ -505,7 +505,7 @@ async fn finalize_stream<'a>(
505505
};
506506
let Some((user_details, avatar_url)) = user_data_map
507507
.get(&ssrc)
508-
.map(|x| (x.value().0.to_owned(), x.value().1.to_owned()))
508+
.map(|x| (x.value().0.clone(), x.value().1.clone()))
509509
else {
510510
warn!("no user details for ssrc {}", ssrc);
511511
return None;

scripty_automod/src/db.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::types::{AutomodRule, AutomodServerConfig};
22

33
pub async fn get_guild_config(guild_id: u64) -> Result<Option<AutomodServerConfig>, sqlx::Error> {
44
let db = scripty_db::get_db();
5-
let mut cfg = match sqlx::query!(
5+
let Some(mut cfg) = sqlx::query!(
66
"SELECT * FROM automod_config WHERE guild_id = $1",
77
guild_id as i64
88
)
@@ -18,9 +18,8 @@ pub async fn get_guild_config(guild_id: u64) -> Result<Option<AutomodServerConfi
1818
row.log_channel_id as u64,
1919
row.log_recording,
2020
)
21-
}) {
22-
Some(cfg) => cfg,
23-
None => return Ok(None),
21+
}) else {
22+
return Ok(None);
2423
};
2524

2625
// fetch rules

scripty_bot/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ pub async fn entrypoint() {
3131
.options(framework_opts::get_framework_opts())
3232
.build();
3333
let data = Arc::new(Data::new());
34-
let Ok(_) = CLIENT_DATA.set(data.clone()) else {
35-
panic!("client data set more than once: bug?")
36-
};
34+
if CLIENT_DATA.set(data.clone()).is_err() {
35+
unreachable!("client data set more than once: bug?")
36+
}
3737

3838
let songbird = scripty_audio_handler::Songbird::serenity_from_config(
3939
scripty_audio_handler::get_songbird_config(),
@@ -48,7 +48,7 @@ pub async fn entrypoint() {
4848
}
4949
let http = http.build();
5050
if let Some(ratelimiter) = &http.ratelimiter {
51-
ratelimiter.set_ratelimit_callback(Box::new(handler::ratelimit))
51+
ratelimiter.set_ratelimit_callback(Box::new(handler::ratelimit));
5252
}
5353

5454
let mut client =

scripty_bot_utils/src/error/error_type.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ pub struct Error {
1717

1818
impl Debug for Error {
1919
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
20-
f.debug_struct("Error").field("err", &self.err).finish()
20+
f.debug_struct("Error")
21+
.field("err", &self.err)
22+
.finish_non_exhaustive()
2123
}
2224
}
2325

scripty_bot_utils/src/handler/normal/voice_state_update.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,9 @@ pub async fn voice_state_update(ctx: &Context, new: &VoiceState) {
2828
if let Some(cid) = get_voice_channel_id(guild_id).await {
2929
// GuildRef forces a block here to prevent hold over await
3030
{
31-
let guild = match guild_id.to_guild_cached(&ctx.cache) {
32-
Some(g) => g,
33-
None => {
34-
warn!("guild id {} not found in cache", guild_id);
35-
return;
36-
}
31+
let Some(guild) = guild_id.to_guild_cached(&ctx.cache) else {
32+
warn!("guild id {} not found in cache", guild_id);
33+
return;
3734
};
3835

3936
// iterate through voice states in the guild
@@ -81,7 +78,7 @@ pub async fn voice_state_update(ctx: &Context, new: &VoiceState) {
8178
.map(|x| x.map(|y| y.auto_join))
8279
{
8380
Ok(Some(true)) => {
84-
debug!(%guild_id, "guild has auto join enabled, proceeding with join")
81+
debug!(%guild_id, "guild has auto join enabled, proceeding with join");
8582
}
8683
Ok(Some(false)) => {
8784
// auto join is not enabled, so we don't need to do anything
@@ -111,17 +108,14 @@ pub async fn voice_state_update(ctx: &Context, new: &VoiceState) {
111108
if target_user.bot() {
112109
debug!(%guild_id, "user {} is a bot, not continuing with join", target_user.id);
113110
return;
114-
};
111+
}
115112

116113
// now we need to check the voice channel the user is joining
117114
// discord doesn't give us the channel id, so we need to get it from the guild's voice states
118115
let vs = {
119-
let guild = match guild_id.to_guild_cached(&ctx.cache) {
120-
Some(g) => g,
121-
None => {
122-
warn!(%guild_id, "guild not found in cache");
123-
return;
124-
}
116+
let Some(guild) = guild_id.to_guild_cached(&ctx.cache) else {
117+
warn!(%guild_id, "guild not found in cache");
118+
return;
125119
};
126120

127121
// fetch the user's voice state

scripty_bot_utils/src/prefix_handling.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async fn _dynamic_prefix(
4444
Some(prefix)
4545
}
4646
})
47-
.unwrap_or_else(|| scripty_config::get_config().prefix.to_owned());
47+
.unwrap_or_else(|| scripty_config::get_config().prefix.clone());
4848

4949
scripty_redis::run_transaction::<()>("SETEX", |cmd| {
5050
cmd.arg(format!("prefix_{{{}}}", guild_id.get()))

scripty_commands/src/cmds/admin/cache_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub async fn cache_info(ctx: Context<'_>) -> Result<(), Error> {
4545
is_collection: false,
4646
value: format!("Size: `{size}b`"),
4747
});
48-
};
48+
}
4949
}
5050

5151
fields.sort_by_key(|field| field.size);

scripty_commands/src/cmds/admin/guild_check.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,9 @@ pub async fn check_guilds(ctx: Context<'_>, specified_ratio: f64) -> Result<(),
4343
let mut guild_warnings: Vec<(String, u64, f64)> = Vec::new();
4444

4545
for guild in ctx.serenity_context().cache.guilds() {
46-
let g = match guild.to_guild_cached(ctx.cache()) {
47-
Some(g) => g,
48-
None => {
49-
error_count += 1;
50-
continue;
51-
}
46+
let Some(g) = guild.to_guild_cached(ctx.cache()) else {
47+
error_count += 1;
48+
continue;
5249
};
5350

5451
let member_count = g.member_count;

0 commit comments

Comments
 (0)