Skip to content

Commit 518146b

Browse files
committed
Merge branch 'refactor' into 'main'
refactor: fix clippy lints See merge request Erenoit/discord-bot!24
2 parents b15a4d4 + 3741a55 commit 518146b

File tree

24 files changed

+134
-26
lines changed

24 files changed

+134
-26
lines changed

src/bot/commands/entertainment/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
//! Contains all the entertainment commands.
22
3+
/// meme command.
34
pub mod meme;
5+
/// sus command.
46
pub mod sus;

src/bot/commands/macros.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Macros for the commands.
2+
13
/// Gives [`Server`] and [`Guild`] for the given [`Context`].
24
///
35
/// Most of the commands need these two, so this macro is used to reduce code

src/bot/commands/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ pub mod entertainment;
1717
pub mod music;
1818
pub mod others;
1919

20+
/// Error type for the bot.
2021
type Error = Box<dyn std::error::Error + Send + Sync>;
22+
/// Context type for the bot.
2123
pub type Context<'a> = poise::Context<'a, Data, Error>;
2224

25+
/// The data type for the bot.
2326
pub struct Data;

src/bot/commands/music/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,31 @@
11
//! Contains all the music commands.
22
3+
/// clear command
34
pub mod clear;
5+
/// join command
46
pub mod join;
7+
/// leave command
58
pub mod leave;
9+
/// music command
610
#[allow(clippy::module_inception)]
711
#[cfg(feature = "database")]
812
pub mod music;
13+
/// play command
914
pub mod play;
15+
/// queue command
1016
pub mod queue;
17+
/// repeat command
1118
pub mod repeat;
19+
/// shuffle command
1220
pub mod shuffle;
21+
/// skip command
1322
pub mod skip;
23+
/// stop command
1424
pub mod stop;
1525

1626
use crate::{bot::commands::Context, server::Server};
1727

28+
/// Gets the voice channel id from the context.
1829
fn context_to_voice_channel_id(ctx: &Context<'_>) -> Option<serenity::model::id::ChannelId> {
1930
ctx.guild()
2031
.expect("Guild should be Some")
@@ -23,6 +34,7 @@ fn context_to_voice_channel_id(ctx: &Context<'_>) -> Option<serenity::model::id:
2334
.and_then(|voice_state| voice_state.channel_id)
2435
}
2536

37+
/// Handles the voice channel connection.
2638
async fn handle_vc_connection(ctx: &Context<'_>, server: &Server) -> anyhow::Result<()> {
2739
let bot_vc = server.player.connected_vc().await;
2840
if bot_vc.is_none() {

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/commands/others/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
//! Contains all the commands that don't fit in any other category.
22
3+
/// help command
34
pub mod help;
5+
/// ping command
46
pub mod ping;
7+
/// register command
58
pub mod register;

src/bot/event.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Struct for handling `Discord` events.
2+
13
use std::sync::Arc;
24

35
use serenity::{
@@ -16,6 +18,7 @@ use crate::server::Server;
1618
/// It currently handles `Ready`, `GuildCreate` and `GuildDelete` events.
1719
pub struct Handler;
1820
impl Handler {
21+
/// Creates new [`Handler`] struct.
1922
pub const fn new() -> Self { Self }
2023
}
2124

@@ -32,6 +35,7 @@ impl EventHandler for Handler {
3235
}
3336

3437
log!(info, "{} is online!", (ready.user.name.magenta()));
38+
drop(servers);
3539
}
3640

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

src/bot/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,15 @@ 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.
31+
///
32+
/// # Panics
33+
///
34+
/// This method panics if it cannot run database mitigations or cannot
35+
/// connects to the `Discord`
3036
pub async fn run(&mut self) {
3137
#[cfg(feature = "database")]
3238
get_config!()

src/config/database.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use taplo::dom::Node;
1010
#[cfg(not(feature = "config_file"))]
1111
use crate::config::Node;
1212

13+
/// Database configuration.
1314
#[non_exhaustive]
1415
pub(super) struct DatabaseConfig {
1516
/// Database pool.

src/config/defaults.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,34 @@
44
//! when the config file is not present or when a value is missing from the
55
//! config file.
66
7+
/// Default Prefix
78
pub(super) const PREFIX: &str = "-";
9+
/// Default Auto Register Commands
810
pub(super) const AUTO_REGISTER_COMMANDS: bool = true;
11+
/// Default VC Auto Change
912
#[cfg(feature = "music")]
1013
pub(super) const VC_AUTO_CHANGE: bool = false;
14+
/// Default Enable Spotify
1115
#[cfg(feature = "spotify")]
1216
pub(super) const ENABLE_SPOTIFY: bool = false;
17+
/// Default YT Search Count
1318
#[cfg(feature = "music")]
1419
pub(super) const YT_SEARCH_COUNT: u8 = 5;
20+
/// Default YT Age Restricted
1521
#[cfg(feature = "music")]
1622
pub(super) const YT_AGE_RESTRICTED: bool = false;
23+
/// Default Enable Database
1724
#[cfg(feature = "database")]
1825
pub(super) const ENABLE_DATABASE: bool = true;
26+
/// Default Always Embed
1927
pub(super) const ALWAYS_EMBED: bool = false;
28+
/// Default Random Embed Colors
2029
pub(super) const RANDOM_EMBED_COLORS: bool = false;
30+
/// Default Embed Success Color
2131
pub(super) const SUCCESS_COLOR: u32 = 0x00FF00;
32+
/// Default Embed Normal Color
2233
pub(super) const NORMAL_COLOR: u32 = 0x0000FF;
34+
/// Default Embed Error Color
2335
pub(super) const ERROR_COLOR: u32 = 0xFF0000;
36+
/// Default Interaction Time Limit
2437
pub(super) const INTERACTION_TIME_LIMIT: u64 = 30;

0 commit comments

Comments
 (0)