Skip to content

Commit

Permalink
Merge pull request #34 from jamesbt365/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
InfinityGhost authored May 9, 2024
2 parents 6288847 + 74ab9f6 commit f3568e7
Show file tree
Hide file tree
Showing 9 changed files with 370 additions and 337 deletions.
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

0 comments on commit f3568e7

Please sign in to comment.