Skip to content

Commit 36ccdf2

Browse files
committed
docs: simplify comments
1 parent ce9bca7 commit 36ccdf2

4 files changed

Lines changed: 9 additions & 20 deletions

File tree

src/abstraction/providers/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub struct ProviderPlatformInfo {
3636
pub summary: Option<String>,
3737
}
3838

39-
/// Slash-command choice parameter. Order here is what shows up in Discord's dropdown.
39+
/// Order here is the order shown in Discord's dropdown.
4040
#[derive(poise::ChoiceParameter, Clone, Copy, Debug)]
4141
pub enum ProviderChoice {
4242
#[name = "IGDB"]
@@ -76,7 +76,7 @@ impl ProviderChoice {
7676
}
7777

7878
/// Order in which the identification flow tries to enrich the card.
79-
/// `EmuReady` and `TheGamesDB` are intentionally excluded — they have no read endpoints.
79+
/// `EmuReady` and `TheGamesDB` are intentionally excluded. They have no read endpoints.
8080
pub const ENRICHMENT_PRIORITY: &[MetadataProvider] = &[
8181
MetadataProvider::Igdb,
8282
MetadataProvider::MobyGames,
@@ -87,7 +87,7 @@ pub const ENRICHMENT_PRIORITY: &[MetadataProvider] = &[
8787
MetadataProvider::SteamGridDb,
8888
];
8989

90-
/// All providers, in the order rendered as columns in the list tables.
90+
/// Order here determines the column order in the `/list` tables.
9191
pub const ALL_PROVIDERS: &[MetadataProvider] = &[
9292
MetadataProvider::Igdb,
9393
MetadataProvider::MobyGames,

src/command/playmatch.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -886,9 +886,8 @@ pub(crate) struct SuggestionMessageHandleData {
886886
pub comment: Option<String>,
887887
}
888888

889-
/// Posts the staff card (if `existing_message_id` is None) and then waits on the Approve/Decline
890-
/// buttons. Called inline from the suggest commands (with `None`) and from the external-suggestion
891-
/// poller (with `None` for new posts and `Some(id)` to re-attach to a pre-restart message).
889+
/// Posts the staff card and waits on the Approve/Decline buttons.
890+
/// Pass `Some(message_id)` to re-attach to an existing card instead of posting a new one.
892891
pub(crate) async fn handle_suggestion_message(
893892
data: SuggestionMessageHandleData,
894893
existing_message_id: Option<serenity::all::MessageId>,

src/events/suggestion_poller.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ pub async fn run(ctx: Context, data: Arc<CommandData>) {
4747
let channel_id = ChannelId::new(*SUGGESTION_CHANNEL_ID);
4848
let seen: Arc<Mutex<HashSet<Uuid>>> = Arc::new(Mutex::new(HashSet::new()));
4949

50-
// Phase 1 + 2: scan channel history, build seen set, spawn recovery for each pending one.
5150
match channel_id
5251
.widen()
5352
.messages(&http, GetMessages::new().limit(CHANNEL_SCAN_LIMIT))
@@ -73,9 +72,9 @@ pub async fn run(ctx: Context, data: Arc<CommandData>) {
7372
}
7473
}
7574

76-
// Phase 3: poll loop.
75+
// The first tick fires immediately so we catch up on suggestions submitted while the
76+
// bot was offline. Subsequent ticks wait the full interval.
7777
let mut tick = interval(Duration::from_secs(*POLL_INTERVAL_SECS));
78-
tick.tick().await; // consume immediate first tick
7978
loop {
8079
tick.tick().await;
8180

@@ -173,7 +172,7 @@ fn spawn_recovery(
173172
Ok(r) => r.into_inner(),
174173
Err(e) => {
175174
debug!(
176-
"suggestion poller: recovery skipped suggestion {suggestion_id} no longer pending: {e}"
175+
"suggestion poller: recovery skipped, suggestion {suggestion_id} no longer pending: {e}"
177176
);
178177
return;
179178
}

src/util/mod.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
extern crate unicode_width;
22
use unicode_width::UnicodeWidthStr;
33

4-
// Function to pad a string to a specified width with spaces
54
fn pad_string(input: &str, width: usize) -> String {
65
let length = UnicodeWidthStr::width(input);
76
if length >= width {
@@ -12,47 +11,39 @@ fn pad_string(input: &str, width: usize) -> String {
1211
}
1312
}
1413

15-
// Define a function to create a Markdown table from a vector of rows with formatting for Discord.
1614
pub fn create_discord_markdown_table(rows: Vec<Vec<String>>) -> String {
1715
let mut result = String::new();
1816

1917
if rows.is_empty() {
2018
return result;
2119
}
2220

23-
// Determine the number of columns from the first row
2421
let columns = rows[0].len();
2522

26-
// Find the maximum width for each column
2723
let mut max_widths = vec![0; columns];
2824
for row in &rows {
2925
for (index, cell) in row.iter().enumerate() {
3026
max_widths[index] =
3127
std::cmp::max(max_widths[index], UnicodeWidthStr::width(cell.as_str()) + 2);
32-
// Adjust for proper Unicode width
3328
}
3429
}
3530

36-
// Create the header separator
3731
let header_separator: Vec<String> = max_widths.iter().map(|&width| "-".repeat(width)).collect();
3832

39-
// Process each row, padding each cell to the max width of its column
4033
for (i, row) in rows.iter().enumerate() {
4134
let padded_row: Vec<String> = row
4235
.iter()
4336
.enumerate()
4437
.map(|(index, cell)| pad_string(cell, max_widths[index]))
4538
.collect();
4639

47-
// Add row to the result
4840
result.push_str(&format!("|{}|\n", padded_row.join("|")));
4941

50-
// Add the header separator after the first row (header)
5142
if i == 0 {
5243
result.push_str(&format!("|{}|\n", header_separator.join("|")));
5344
}
5445
}
5546

56-
// Encapsulate in a monospace code block for Discord
47+
// Wrap in a fenced code block so Discord renders it monospaced.
5748
format!("```\n{result}\n```")
5849
}

0 commit comments

Comments
 (0)