Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor #34

Merged
merged 4 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ regex = "1.10.2"
octocrab = "0.19.0"
reqwest = "0.11.22"
hex = "0.4.3"
to-arraystring = "0.1.3"
15 changes: 4 additions & 11 deletions src/commands/snippets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ async fn autocomplete_snippet<'a>(
.unwrap()
.snippets
.iter()
.map(|s| format!("{}: {}", s.id, s.title))
.map(Snippet::format_output)
.collect()
};

futures::stream::iter(snippet_list)
.filter(move |name| futures::future::ready(name.contains(partial)))
futures::stream::iter(snippet_list).filter(move |name| {
futures::future::ready(name.to_lowercase().contains(&partial.to_lowercase()))
})
}

/// Show a snippet
Expand Down Expand Up @@ -87,14 +88,6 @@ pub async fn create_snippet(
rwlock_guard.snippets.push(snippet);
rwlock_guard.write();

if rwlock_guard.snippets.len() > 25 {
embed = embed.field(
"Warning",
"There are more than 25 snippets, some may not appear in the snippet list.",
false,
);
}

embed
};

Expand Down
4 changes: 1 addition & 3 deletions src/commands/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ pub async fn embed(
Ok(())
}

/// Create an embed in the current channel.
///
///
/// Edits an embed already sent by the embed command.
#[allow(clippy::too_many_arguments)]
#[poise::command(rename = "edit-embed", slash_command, guild_only)]
pub async fn edit_embed(
Expand Down
1 change: 1 addition & 0 deletions src/events/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use poise::serenity_prelude::{self as serenity, Colour, Context, CreateEmbed, Me

use crate::formatting::trim_indent;

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

pub async fn message(ctx: &Context, message: &Message) {
Expand Down
Loading