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

allow only active members to transfer money #85

Merged
merged 5 commits into from
Mar 10, 2024
Merged
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
22 changes: 20 additions & 2 deletions bin/bot/src/discord/slash/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
client::Context,
};
use synixe_events::gear::db::Response;
use synixe_meta::discord::{channel::LOG, role::STAFF, BRODSKY, GUILD};
use synixe_meta::discord::{
channel::LOG,
role::{ACTIVE, STAFF},
BRODSKY, GUILD,
};
use synixe_proc::events_request_2;

use crate::{discord::interaction::Interaction, get_option, get_option_user};
Expand Down Expand Up @@ -128,7 +132,7 @@
.await
}

#[allow(clippy::cast_possible_truncation)]
#[allow(clippy::cast_possible_truncation, clippy::too_many_lines)]
async fn transfer(
ctx: &Context,
command: &CommandInteraction,
Expand All @@ -139,6 +143,20 @@
let Some(user) = get_option_user!(options, "member") else {
return interaction.reply("Invalid member").await;
};

super::requires_roles(
command.user.id,
&[ACTIVE],
&command
.member
.as_ref()
.expect("member should always exist on guild commands")
.roles,
ShouldAsk::Yes(("bank transfer", options)),
&mut interaction,
)
.await?;

Check warning on line 158 in bin/bot/src/discord/slash/bank.rs

View check run for this annotation

Codecov / codecov/patch

bin/bot/src/discord/slash/bank.rs#L147-L158

Added lines #L147 - L158 were not covered by tests

if user != &synixe_meta::discord::BRODSKY && GUILD.member(&ctx, user).await?.user.bot {
return interaction.reply("You can't transfer money to a bot").await;
}
Expand Down
Loading