Skip to content

Commit f3568e7

Browse files
Merge pull request #34 from jamesbt365/refactor
Refactor
2 parents 6288847 + 74ab9f6 commit f3568e7

9 files changed

Lines changed: 370 additions & 337 deletions

File tree

Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ regex = "1.10.2"
2121
octocrab = "0.19.0"
2222
reqwest = "0.11.22"
2323
hex = "0.4.3"
24+
to-arraystring = "0.1.3"

src/commands/snippets.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ async fn autocomplete_snippet<'a>(
2121
.unwrap()
2222
.snippets
2323
.iter()
24-
.map(|s| format!("{}: {}", s.id, s.title))
24+
.map(Snippet::format_output)
2525
.collect()
2626
};
2727

28-
futures::stream::iter(snippet_list)
29-
.filter(move |name| futures::future::ready(name.contains(partial)))
28+
futures::stream::iter(snippet_list).filter(move |name| {
29+
futures::future::ready(name.to_lowercase().contains(&partial.to_lowercase()))
30+
})
3031
}
3132

3233
/// Show a snippet
@@ -87,14 +88,6 @@ pub async fn create_snippet(
8788
rwlock_guard.snippets.push(snippet);
8889
rwlock_guard.write();
8990

90-
if rwlock_guard.snippets.len() > 25 {
91-
embed = embed.field(
92-
"Warning",
93-
"There are more than 25 snippets, some may not appear in the snippet list.",
94-
false,
95-
);
96-
}
97-
9891
embed
9992
};
10093

src/commands/utils.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,7 @@ pub async fn embed(
124124
Ok(())
125125
}
126126

127-
/// Create an embed in the current channel.
128-
///
129-
///
127+
/// Edits an embed already sent by the embed command.
130128
#[allow(clippy::too_many_arguments)]
131129
#[poise::command(rename = "edit-embed", slash_command, guild_only)]
132130
pub async fn edit_embed(

src/events/code.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use poise::serenity_prelude::{self as serenity, Colour, Context, CreateEmbed, Me
66

77
use crate::formatting::trim_indent;
88

9+
// A shade of purple.
910
const ACCENT_COLOUR: Colour = Colour::new(0x8957e5);
1011

1112
pub async fn message(ctx: &Context, message: &Message) {

0 commit comments

Comments
 (0)