mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-05-23 16:50:49 +00:00
Another round of manual linting
Some checks failed
Build and Test / Format check (push) Has been cancelled
Build and Test / Lint (push) Has been cancelled
Build and Test / Test (push) Has been cancelled
Build and Test / Check dependency hash (push) Has been cancelled
Build and Test / Build (push) Has been cancelled
Some checks failed
Build and Test / Format check (push) Has been cancelled
Build and Test / Lint (push) Has been cancelled
Build and Test / Test (push) Has been cancelled
Build and Test / Check dependency hash (push) Has been cancelled
Build and Test / Build (push) Has been cancelled
This commit is contained in:
parent
c5f46dd7fe
commit
a4ac2b9e2c
8 changed files with 38 additions and 38 deletions
|
@ -11,3 +11,6 @@ members = [
|
||||||
]
|
]
|
||||||
[workspace.lints.rust]
|
[workspace.lints.rust]
|
||||||
deprecated = "allow"
|
deprecated = "allow"
|
||||||
|
|
||||||
|
[workspace.lints.clippy]
|
||||||
|
too_many_arguments = "allow"
|
||||||
|
|
|
@ -188,7 +188,7 @@ impl OsuUser {
|
||||||
|
|
||||||
impl OsuUser {
|
impl OsuUser {
|
||||||
/// Stores the user.
|
/// Stores the user.
|
||||||
pub async fn store<'a>(&self, conn: &mut Transaction<'a, Database>) -> Result<bool> {
|
pub async fn store(&self, conn: &mut Transaction<'_, Database>) -> Result<bool> {
|
||||||
let old_user_id = {
|
let old_user_id = {
|
||||||
query!(
|
query!(
|
||||||
r#"SELECT id as "id: i64" FROM osu_users WHERE user_id = ?"#,
|
r#"SELECT id as "id: i64" FROM osu_users WHERE user_id = ?"#,
|
||||||
|
|
|
@ -337,7 +337,7 @@ async fn beatmap<U: HasOsuEnv>(
|
||||||
EmbedType::Beatmap(beatmap, bmode, info, bmmods) => {
|
EmbedType::Beatmap(beatmap, bmode, info, bmmods) => {
|
||||||
let (beatmap, info, mods) =
|
let (beatmap, info, mods) =
|
||||||
if mods.is_none() && mode.is_none_or(|v| v == bmode.unwrap_or(beatmap.mode)) {
|
if mods.is_none() && mode.is_none_or(|v| v == bmode.unwrap_or(beatmap.mode)) {
|
||||||
(*beatmap, info, bmmods)
|
(*beatmap, *info, bmmods)
|
||||||
} else {
|
} else {
|
||||||
let mode = bmode.unwrap_or(beatmap.mode);
|
let mode = bmode.unwrap_or(beatmap.mode);
|
||||||
let mods = match mods {
|
let mods = match mods {
|
||||||
|
@ -678,7 +678,7 @@ async fn parse_map_input(
|
||||||
return Ok(EmbedType::Beatmap(
|
return Ok(EmbedType::Beatmap(
|
||||||
Box::new(beatmap),
|
Box::new(beatmap),
|
||||||
None,
|
None,
|
||||||
info,
|
Box::new(info),
|
||||||
Mods::NOMOD.clone(),
|
Mods::NOMOD.clone(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,7 +194,7 @@ mod scores {
|
||||||
header: header.clone(),
|
header: header.clone(),
|
||||||
scores,
|
scores,
|
||||||
};
|
};
|
||||||
let Some(content) = p.to_table(0, usize::max_value()).await? else {
|
let Some(content) = p.format_table(0, usize::MAX).await? else {
|
||||||
on.apply_edit(CreateReply::default().content("No plays found"))
|
on.apply_edit(CreateReply::default().content("No plays found"))
|
||||||
.await?;
|
.await?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
@ -240,7 +240,7 @@ mod scores {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Scores> Paginate<T> {
|
impl<T: Scores> Paginate<T> {
|
||||||
async fn to_table(&mut self, start: usize, end: usize) -> Result<Option<String>> {
|
async fn format_table(&mut self, start: usize, end: usize) -> Result<Option<String>> {
|
||||||
let scores = self.scores.get_range(start..end).await?;
|
let scores = self.scores.get_range(start..end).await?;
|
||||||
if scores.is_empty() {
|
if scores.is_empty() {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
|
@ -374,7 +374,7 @@ mod scores {
|
||||||
let start = page * ITEMS_PER_PAGE;
|
let start = page * ITEMS_PER_PAGE;
|
||||||
let end = start + ITEMS_PER_PAGE;
|
let end = start + ITEMS_PER_PAGE;
|
||||||
|
|
||||||
let Some(score_table) = self.to_table(start, end).await? else {
|
let Some(score_table) = self.format_table(start, end).await? else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
let mut content = serenity::utils::MessageBuilder::new();
|
let mut content = serenity::utils::MessageBuilder::new();
|
||||||
|
|
|
@ -254,7 +254,7 @@ pub fn hook<'a>(
|
||||||
.then(|l| async move {
|
.then(|l| async move {
|
||||||
match l.embed {
|
match l.embed {
|
||||||
EmbedType::Beatmap(b, mode, info, mods) => {
|
EmbedType::Beatmap(b, mode, info, mods) => {
|
||||||
handle_beatmap(ctx, &b, info, l.link, mode, mods, msg)
|
handle_beatmap(ctx, &b, *info, l.link, mode, mods, msg)
|
||||||
.await
|
.await
|
||||||
.pls_ok();
|
.pls_ok();
|
||||||
let bm = super::BeatmapWithMode(*b, mode);
|
let bm = super::BeatmapWithMode(*b, mode);
|
||||||
|
@ -277,7 +277,7 @@ pub fn hook<'a>(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_beatmap<'a, 'b>(
|
async fn handle_beatmap(
|
||||||
ctx: &Context,
|
ctx: &Context,
|
||||||
beatmap: &Beatmap,
|
beatmap: &Beatmap,
|
||||||
info: BeatmapInfoWithPP,
|
info: BeatmapInfoWithPP,
|
||||||
|
@ -316,7 +316,7 @@ async fn handle_beatmap<'a, 'b>(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_beatmapset<'a, 'b>(
|
async fn handle_beatmapset(
|
||||||
ctx: &Context,
|
ctx: &Context,
|
||||||
beatmaps: Vec<Beatmap>,
|
beatmaps: Vec<Beatmap>,
|
||||||
link: &'_ str,
|
link: &'_ str,
|
||||||
|
|
|
@ -11,7 +11,7 @@ use super::{oppai_cache::BeatmapInfoWithPP, OsuEnv};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum EmbedType {
|
pub enum EmbedType {
|
||||||
Beatmap(Box<Beatmap>, Option<Mode>, BeatmapInfoWithPP, Mods),
|
Beatmap(Box<Beatmap>, Option<Mode>, Box<BeatmapInfoWithPP>, Mods),
|
||||||
Beatmapset(Vec<Beatmap>, Option<Mode>),
|
Beatmapset(Vec<Beatmap>, Option<Mode>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ impl EmbedType {
|
||||||
.await
|
.await
|
||||||
.map(|b| b.get_possible_pp_with(mode, &mods))?
|
.map(|b| b.get_possible_pp_with(mode, &mods))?
|
||||||
};
|
};
|
||||||
Ok(Self::Beatmap(Box::new(bm), mode, info, mods))
|
Ok(Self::Beatmap(Box::new(bm), mode, Box::new(info), mods))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn from_beatmapset_id(
|
pub(crate) async fn from_beatmapset_id(
|
||||||
|
|
|
@ -449,31 +449,28 @@ pub async fn forcesave(ctx: &Context, msg: &Message, mut args: Args) -> CommandR
|
||||||
async fn add_user(target: serenity::model::id::UserId, user: &User, env: &OsuEnv) -> Result<()> {
|
async fn add_user(target: serenity::model::id::UserId, user: &User, env: &OsuEnv) -> Result<()> {
|
||||||
let modes = [Mode::Std, Mode::Taiko, Mode::Catch, Mode::Mania]
|
let modes = [Mode::Std, Mode::Taiko, Mode::Catch, Mode::Mania]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|mode| {
|
.map(|mode| async move {
|
||||||
let mode = mode;
|
let pp = async {
|
||||||
async move {
|
env.client
|
||||||
let pp = async {
|
.user(&UserID::ID(user.id), |f| f.mode(mode))
|
||||||
env.client
|
.await
|
||||||
.user(&UserID::ID(user.id), |f| f.mode(mode))
|
.pls_ok()
|
||||||
.await
|
.unwrap_or(None)
|
||||||
.pls_ok()
|
.and_then(|u| u.pp)
|
||||||
.unwrap_or(None)
|
};
|
||||||
.and_then(|u| u.pp)
|
let map_length_age = UserExtras::from_user(env, user, mode);
|
||||||
};
|
let (pp, ex) = join!(pp, map_length_age);
|
||||||
let map_length_age = UserExtras::from_user(env, user, mode);
|
pp.zip(ex.ok()).map(|(pp, ex)| {
|
||||||
let (pp, ex) = join!(pp, map_length_age);
|
(
|
||||||
pp.zip(ex.ok()).map(|(pp, ex)| {
|
mode,
|
||||||
(
|
OsuUserMode {
|
||||||
mode,
|
pp,
|
||||||
OsuUserMode {
|
map_length: ex.map_length,
|
||||||
pp,
|
map_age: ex.map_age,
|
||||||
map_length: ex.map_length,
|
last_update: Utc::now(),
|
||||||
map_age: ex.map_age,
|
},
|
||||||
last_update: Utc::now(),
|
)
|
||||||
},
|
})
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.collect::<stream::FuturesOrdered<_>>()
|
.collect::<stream::FuturesOrdered<_>>()
|
||||||
.filter_map(future::ready)
|
.filter_map(future::ready)
|
||||||
|
@ -832,7 +829,7 @@ pub(crate) async fn load_beatmap_from_channel(
|
||||||
Some(EmbedType::Beatmap(
|
Some(EmbedType::Beatmap(
|
||||||
Box::new(b),
|
Box::new(b),
|
||||||
m,
|
m,
|
||||||
info,
|
Box::new(info),
|
||||||
Mods::NOMOD.clone(),
|
Mods::NOMOD.clone(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,7 +160,7 @@ impl<T: FetchScores> Scores for ScoresFetcher<T> {
|
||||||
|
|
||||||
/// Get all scores.
|
/// Get all scores.
|
||||||
async fn get_all(mut self) -> Result<Vec<Score>> {
|
async fn get_all(mut self) -> Result<Vec<Score>> {
|
||||||
let _ = self.get_range(0..usize::max_value()).await?;
|
let _ = self.get_range(0..usize::MAX).await?;
|
||||||
Ok(self.scores)
|
Ok(self.scores)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue