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

Add support for custom fail emoji #180

Merged
merged 2 commits into from
Sep 2, 2022
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
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ BOT_ID=
## Emojis
SUCCESS_EMOJI_NAME=
SUCCESS_EMOJI_ID=
FAIL_EMOJI_NAME=
FAIL_EMOJI_ID=
LOADING_EMOJI_NAME=
LOADING_EMOJI_ID=
LOGO_EMOJI_NAME=
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ chrono = "0.4.19"


[dependencies.serenity]
version = "0.11"
version = "=0.11.1"
default-features = false
features = ["collector", "gateway", "builder", "standard_framework", "http", "model", "client", "framework", "utils", "rustls_backend"]

Expand Down
2 changes: 2 additions & 0 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ pub async fn fill(
let emoji_identifiers = [
"SUCCESS_EMOJI_ID",
"SUCCESS_EMOJI_NAME",
"FAIL_EMOJI_NAME",
"FAIL_EMOJI_ID",
"LOADING_EMOJI_ID",
"LOADING_EMOJI_NAME",
"LOGO_EMOJI_NAME",
Expand Down
26 changes: 18 additions & 8 deletions src/utls/discordhelpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,11 @@ pub async fn send_completion_react(
success: bool,
) -> Result<Reaction, serenity::Error> {
let reaction;
if success {
{
let data = ctx.data.read().await;
let botinfo_lock = data.get::<ConfigCache>().unwrap();
let botinfo = botinfo_lock.read().await;
let data = ctx.data.read().await;
let botinfo_lock = data.get::<ConfigCache>().unwrap();
let botinfo = botinfo_lock.read().await;
match success {
true => {
if let Some(success_id) = botinfo.get("SUCCESS_EMOJI_ID") {
let success_name = botinfo
.get("SUCCESS_EMOJI_NAME")
Expand All @@ -230,10 +230,20 @@ pub async fn send_completion_react(
reaction = ReactionType::Unicode(String::from("✅"));
}
}
} else {
reaction = ReactionType::Unicode(String::from("❌"));
false => {
if let Some(fail_id) = botinfo.get("FAIL_EMOJI_ID") {
let fail_name = botinfo
.get("FAIL_EMOJI_NAME")
.expect("Unable to find fail emoji name")
.clone();
reaction =
discordhelpers::build_reaction(fail_id.parse::<u64>().unwrap(), &fail_name);
} else {
reaction = ReactionType::Unicode(String::from("❌"));
}
}
}
return msg.react(&ctx.http, reaction).await;
msg.react(&ctx.http, reaction).await
}

// Certain compiler outputs use unicode control characters that
Expand Down