Skip to content

Commit

Permalink
0.6.1 - Fix Whitelist Link
Browse files Browse the repository at this point in the history
  • Loading branch information
ShayBox committed Nov 7, 2024
1 parent ba6df3b commit b83d12b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "shaysbot"
version = "0.6.0"
version = "0.6.1"
authors = ["Shayne Hartford <shaybox@shaybox.com>"]
edition = "2021"
description = "My personal Minecraft bot using Azalea"
Expand Down
38 changes: 28 additions & 10 deletions src/plugins/commands/whitelist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ pub fn handle_whitelist_command_event(
continue;
};

let Some((uuid, _info)) = tab_list
.iter()
.find(|(_, info)| info.profile.name == username)
else {
whisper_event.content = String::from("[404] Player not found");
whisper_events.send(whisper_event);
continue;
};

whisper_event.content = match action.as_ref() {
"add" => {
let Some((uuid, _info)) = tab_list
.iter()
.find(|(_, info)| info.profile.name == username)
else {
whisper_event.content = String::from("[404] Player not found");
whisper_events.send(whisper_event);
continue;
};

if settings.whitelist.contains_key(uuid) {
String::from("[409] Already whitelisted.")
} else {
Expand All @@ -87,6 +87,15 @@ pub fn handle_whitelist_command_event(
}
}
"remove" => {
let Some((uuid, _info)) = tab_list
.iter()
.find(|(_, info)| info.profile.name == username)
else {
whisper_event.content = String::from("[404] Player not found");
whisper_events.send(whisper_event);
continue;
};

if settings.whitelist.contains_key(uuid) {
settings.whitelist.remove(uuid);
settings.save().expect("Failed to save settings");
Expand All @@ -100,7 +109,16 @@ pub fn handle_whitelist_command_event(
CommandSender::Discord(_) => {
String::from("[403] You must run this sub-command in-game")
}
CommandSender::Minecraft(_) => {
CommandSender::Minecraft(sender) => {
let Some((uuid, _info)) = tab_list
.iter()
.find(|(_, info)| &info.profile.name == sender)
else {
whisper_event.content = String::from("[404] Sender not found");
whisper_events.send(whisper_event);
continue;
};

settings.whitelist.insert(*uuid, Some(username));
settings.save().expect("Failed to save settings");

Expand Down

0 comments on commit b83d12b

Please sign in to comment.