mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-19 00:38:54 +00:00
osu: add passes_only flag to recent command
This commit is contained in:
parent
068dd48550
commit
487f8647ba
2 changed files with 13 additions and 2 deletions
|
@ -119,6 +119,7 @@ async fn recent<U: HasOsuEnv>(
|
||||||
#[min = 1]
|
#[min = 1]
|
||||||
#[max = 50]
|
#[max = 50]
|
||||||
index: Option<u8>,
|
index: Option<u8>,
|
||||||
|
#[description = "Only include passed scores"] passes_only: Option<bool>,
|
||||||
#[description = "Score listing style"] style: Option<ScoreListStyle>,
|
#[description = "Score listing style"] style: Option<ScoreListStyle>,
|
||||||
#[description = "Game mode"] mode: Option<Mode>,
|
#[description = "Game mode"] mode: Option<Mode>,
|
||||||
#[description = "osu! username"] username: Option<String>,
|
#[description = "osu! username"] username: Option<String>,
|
||||||
|
@ -127,6 +128,7 @@ async fn recent<U: HasOsuEnv>(
|
||||||
let env = ctx.data().osu_env();
|
let env = ctx.data().osu_env();
|
||||||
let args = arg_from_username_or_discord(username, discord_name);
|
let args = arg_from_username_or_discord(username, discord_name);
|
||||||
let style = style.unwrap_or(ScoreListStyle::Table);
|
let style = style.unwrap_or(ScoreListStyle::Table);
|
||||||
|
let include_fails = !passes_only.unwrap_or(false);
|
||||||
|
|
||||||
let args = ListingArgs::from_params(env, index, style, mode, args, ctx.author().id).await?;
|
let args = ListingArgs::from_params(env, index, style, mode, args, ctx.author().id).await?;
|
||||||
|
|
||||||
|
@ -134,7 +136,9 @@ async fn recent<U: HasOsuEnv>(
|
||||||
|
|
||||||
let osu_client = &env.client;
|
let osu_client = &env.client;
|
||||||
let plays = osu_client
|
let plays = osu_client
|
||||||
.user_recent(UserID::ID(args.user.id), |f| f.mode(args.mode).limit(50))
|
.user_recent(UserID::ID(args.user.id), |f| {
|
||||||
|
f.mode(args.mode).include_fails(include_fails).limit(50)
|
||||||
|
})
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
handle_listing(ctx, plays, args, |_, b| b, "recent").await
|
handle_listing(ctx, plays, args, |_, b| b, "recent").await
|
||||||
|
|
|
@ -248,6 +248,7 @@ pub mod builders {
|
||||||
user: UserID,
|
user: UserID,
|
||||||
mode: Option<Mode>,
|
mode: Option<Mode>,
|
||||||
limit: Option<u8>,
|
limit: Option<u8>,
|
||||||
|
include_fails: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UserScoreRequestBuilder {
|
impl UserScoreRequestBuilder {
|
||||||
|
@ -257,6 +258,7 @@ pub mod builders {
|
||||||
user,
|
user,
|
||||||
mode: None,
|
mode: None,
|
||||||
limit: None,
|
limit: None,
|
||||||
|
include_fails: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,11 +272,16 @@ pub mod builders {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn include_fails(&mut self, include_fails: bool) -> &mut Self {
|
||||||
|
self.include_fails = include_fails;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) async fn build(self, client: &OsuClient) -> Result<Vec<models::Score>> {
|
pub(crate) async fn build(self, client: &OsuClient) -> Result<Vec<models::Score>> {
|
||||||
let scores = handle_not_found({
|
let scores = handle_not_found({
|
||||||
let mut r = client.rosu.user_scores(self.user);
|
let mut r = client.rosu.user_scores(self.user);
|
||||||
r = match self.score_type {
|
r = match self.score_type {
|
||||||
UserScoreType::Recent => r.recent().include_fails(true),
|
UserScoreType::Recent => r.recent().include_fails(self.include_fails),
|
||||||
UserScoreType::Best => r.best(),
|
UserScoreType::Best => r.best(),
|
||||||
UserScoreType::Pin => r.pinned(),
|
UserScoreType::Pin => r.pinned(),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue