Skip to content

Commit 3741a55

Browse files
committed
refactor: other small changes to satisfy clippy
1 parent 9ff8641 commit 3741a55

File tree

5 files changed

+29
-26
lines changed

5 files changed

+29
-26
lines changed

src/bot/commands/music/music.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ pub async fn list(ctx: Context<'_>) -> Result<(), Error> {
207207
.await?
208208
.iter()
209209
.for_each(|result| {
210-
_ = writeln!(
210+
writeln!(
211211
msg,
212212
"**{}**: <{}>",
213213
result
@@ -216,7 +216,8 @@ pub async fn list(ctx: Context<'_>) -> Result<(), Error> {
216216
.expect("There is a `-` in prefix. This cannot fail.")
217217
.1,
218218
result.value
219-
);
219+
)
220+
.ok();
220221
});
221222

222223
msg += "\n";

src/bot/event.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ impl EventHandler for Handler {
3535
}
3636

3737
log!(info, "{} is online!", (ready.user.name.magenta()));
38+
drop(servers);
3839
}
3940

4041
async fn guild_create(&self, _ctx: Context, guild: Guild, is_new: bool) {

src/bot/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub struct Bot;
2424

2525
impl Bot {
2626
/// Creates a new instance of the bot.
27+
#[must_use]
2728
pub const fn new() -> Self { Self }
2829

2930
/// Runs the bot.

src/messager.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ macro_rules! selection {
191191

192192
let mut msg = String::with_capacity(1024);
193193

194-
_ = writeln!(msg, "**{}**", $title);
194+
writeln!(msg, "**{}**", $title).ok();
195195

196196
for (i, element) in $list.iter().enumerate() {
197-
_ = write!(msg, "{}) ", i + 1);
197+
write!(msg, "{}) ", i + 1).ok();
198198
msg.push_str(&element.0);
199199
msg.push('\n');
200200
}
@@ -215,15 +215,15 @@ macro_rules! selection {
215215
/// This is an inner function for `selection!()` macro. Do not use!
216216
macro_rules! selection_inner {
217217
(clear, $ctx:expr, $interaction:ident) => {
218-
_ = $interaction
218+
$interaction
219219
.create_interaction_response($ctx.serenity_context(), |r| {
220220
r.kind(serenity::model::application::interaction::InteractionResponseType::UpdateMessage)
221221
.interaction_response_data(|d| {
222222
d.content("An action has already been taken.")
223223
.set_components(serenity::builder::CreateComponents::default())
224224
})
225225
})
226-
.await;
226+
.await.ok();
227227
};
228228
(get_interaction, $ctx:expr, $res:ident, $n:lifetime, $def_return:expr) => {
229229
{
@@ -240,11 +240,11 @@ macro_rules! selection_inner {
240240
std::time::Duration::from_secs(get_config!().message_interaction_time_limit())
241241
).await else
242242
{
243-
_ = handle.edit($ctx, |m| {
243+
handle.edit($ctx, |m| {
244244
m.content("Interaction timed out.").components(|c| {
245245
c.create_action_row(|row| row)
246246
})
247-
}).await;
247+
}).await.ok();
248248
break $n $def_return;
249249
};
250250

src/player/mod.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ impl Player {
9696
}
9797

9898
if let Some(call_mutex) = get_call_mutex!(self.guild_id) {
99-
let mut call = call_mutex.lock().await;
100-
101-
call.leave()
99+
call_mutex
100+
.lock()
101+
.await
102+
.leave()
102103
.await
103104
.expect("There should be no error while leaving the call");
104105
}
@@ -154,13 +155,10 @@ impl Player {
154155
if now_playing.is_some() {
155156
(*now_playing).take().expect("Cannot be None at this point")
156157
} else {
157-
let Some(song) = self.song_queue
158-
.lock()
159-
.await
160-
.pop_front() else {
161-
self.stop_stream().await;
162-
return;
163-
};
158+
let Some(song) = self.song_queue.lock().await.pop_front() else {
159+
self.stop_stream().await;
160+
return;
161+
};
164162
song
165163
}
166164
},
@@ -174,20 +172,21 @@ impl Player {
174172
},
175173
};
176174

177-
let mut call = call_mutex.lock().await;
178-
_ = call
175+
call_mutex
176+
.lock()
177+
.await
179178
.play_source(source)
180179
.add_event(Event::Track(TrackEvent::End), SongEnd {
181180
guild_id: self.guild_id,
182-
});
181+
})
182+
.ok();
183183
*self.now_playing.lock().await = Some(next_song);
184184
}
185185

186186
/// Stops all playing songs.
187187
pub async fn stop_stream(&self) {
188188
if let Some(call_mutex) = get_call_mutex!(self.guild_id) {
189-
let mut call = call_mutex.lock().await;
190-
call.stop();
189+
call_mutex.lock().await.stop();
191190
*self.now_playing.lock().await = None;
192191
}
193192
}
@@ -299,12 +298,13 @@ impl Player {
299298
let song_str = song.to_string();
300299

301300
if selected {
302-
_ = writeln!(
301+
writeln!(
303302
s,
304303
"**{selected_char}{selected_whitespace}{number_style}{song_str}**"
305-
);
304+
)
305+
.ok();
306306
} else {
307-
_ = writeln!(s, "{normal_whitespace}{number_style}{song_str}");
307+
writeln!(s, "{normal_whitespace}{number_style}{song_str}").ok();
308308
}
309309
}
310310

0 commit comments

Comments
 (0)