mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-20 01:08:55 +00:00
One round of cargo clippy
This commit is contained in:
parent
4bdab3cefb
commit
4a1853532a
6 changed files with 9 additions and 14 deletions
|
@ -12,7 +12,7 @@ fn unwrap_or_ref<'a, T: ?Sized, B: Borrow<T>>(opt: &'a Option<B>, default: &'a T
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create an embed representing the user.
|
/// Create an embed representing the user.
|
||||||
pub fn user_embed<'a>(user: &User) -> CreateEmbed {
|
pub fn user_embed(user: &User) -> CreateEmbed {
|
||||||
let rank = unwrap_or_ref(&user.rank, "Unranked").to_title_case();
|
let rank = unwrap_or_ref(&user.rank, "Unranked").to_title_case();
|
||||||
let max_rank = unwrap_or_ref(&user.max_rank, "Unranked").to_title_case();
|
let max_rank = unwrap_or_ref(&user.max_rank, "Unranked").to_title_case();
|
||||||
let rating = user.rating.unwrap_or(1500);
|
let rating = user.rating.unwrap_or(1500);
|
||||||
|
@ -60,7 +60,7 @@ pub fn user_embed<'a>(user: &User) -> CreateEmbed {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets an embed of the Rating Change.
|
/// Gets an embed of the Rating Change.
|
||||||
pub fn rating_change_embed<'a>(
|
pub fn rating_change_embed(
|
||||||
rating_change: &RatingChange,
|
rating_change: &RatingChange,
|
||||||
user: &User,
|
user: &User,
|
||||||
contest: &Contest,
|
contest: &Contest,
|
||||||
|
|
|
@ -152,7 +152,7 @@ fn parse<'a>(
|
||||||
matches
|
matches
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_info_message<'a>(info: &[(ContestOrProblem, &str)]) -> CreateEmbed {
|
fn print_info_message(info: &[(ContestOrProblem, &str)]) -> CreateEmbed {
|
||||||
let (problems, contests): (Vec<_>, Vec<_>) = info.iter().partition(|(v, _)| match v {
|
let (problems, contests): (Vec<_>, Vec<_>) = info.iter().partition(|(v, _)| match v {
|
||||||
ContestOrProblem::Problem(_) => true,
|
ContestOrProblem::Problem(_) => true,
|
||||||
ContestOrProblem::Contest(_, _) => false,
|
ContestOrProblem::Contest(_, _) => false,
|
||||||
|
|
|
@ -67,7 +67,7 @@ pub async fn choose(ctx: &Context, m: &Message, mut args: Args) -> CommandResult
|
||||||
let channel = m.channel_id.to_channel(&ctx).await?;
|
let channel = m.channel_id.to_channel(&ctx).await?;
|
||||||
if let Channel::Guild(channel) = channel {
|
if let Channel::Guild(channel) = channel {
|
||||||
Ok(channel
|
Ok(channel
|
||||||
.members(&ctx)?
|
.members(ctx)?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|v| !v.user.bot) // Filter out bots
|
.filter(|v| !v.user.bot) // Filter out bots
|
||||||
.filter(|v| {
|
.filter(|v| {
|
||||||
|
|
|
@ -144,12 +144,7 @@ fn beatmap_title(
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn beatmap_embed<'a>(
|
pub fn beatmap_embed(b: &'_ Beatmap, m: Mode, mods: Mods, info: BeatmapInfoWithPP) -> CreateEmbed {
|
||||||
b: &'_ Beatmap,
|
|
||||||
m: Mode,
|
|
||||||
mods: Mods,
|
|
||||||
info: BeatmapInfoWithPP,
|
|
||||||
) -> CreateEmbed {
|
|
||||||
let diff = b.difficulty.apply_mods(mods, info.0.stars);
|
let diff = b.difficulty.apply_mods(mods, info.0.stars);
|
||||||
CreateEmbed::new()
|
CreateEmbed::new()
|
||||||
.title(beatmap_title(&b.artist, &b.title, &b.difficulty_name, mods))
|
.title(beatmap_title(&b.artist, &b.title, &b.difficulty_name, mods))
|
||||||
|
@ -178,7 +173,7 @@ pub fn beatmap_embed<'a>(
|
||||||
|
|
||||||
const MAX_DIFFS: usize = 25 - 4;
|
const MAX_DIFFS: usize = 25 - 4;
|
||||||
|
|
||||||
pub fn beatmapset_embed<'a>(bs: &'_ [Beatmap], m: Option<Mode>) -> CreateEmbed {
|
pub fn beatmapset_embed(bs: &'_ [Beatmap], m: Option<Mode>) -> CreateEmbed {
|
||||||
let too_many_diffs = bs.len() > MAX_DIFFS;
|
let too_many_diffs = bs.len() > MAX_DIFFS;
|
||||||
let b: &Beatmap = &bs[0];
|
let b: &Beatmap = &bs[0];
|
||||||
let mut m = CreateEmbed::new()
|
let mut m = CreateEmbed::new()
|
||||||
|
@ -266,7 +261,7 @@ pub(crate) fn score_embed<'a>(
|
||||||
|
|
||||||
impl<'a> ScoreEmbedBuilder<'a> {
|
impl<'a> ScoreEmbedBuilder<'a> {
|
||||||
#[allow(clippy::many_single_char_names)]
|
#[allow(clippy::many_single_char_names)]
|
||||||
pub fn build<'b>(&mut self) -> CreateEmbed {
|
pub fn build(&mut self) -> CreateEmbed {
|
||||||
let mode = self.bm.mode();
|
let mode = self.bm.mode();
|
||||||
let b = &self.bm.0;
|
let b = &self.bm.0;
|
||||||
let s = self.s;
|
let s = self.s;
|
||||||
|
|
|
@ -246,7 +246,7 @@ pub async fn save(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult
|
||||||
let reaction = reply.react(&ctx, '👌').await?;
|
let reaction = reply.react(&ctx, '👌').await?;
|
||||||
let completed = loop {
|
let completed = loop {
|
||||||
let emoji = reaction.emoji.clone();
|
let emoji = reaction.emoji.clone();
|
||||||
let user_reaction = collector::ReactionCollector::new(&ctx)
|
let user_reaction = collector::ReactionCollector::new(ctx)
|
||||||
.message_id(reply.id)
|
.message_id(reply.id)
|
||||||
.author_id(msg.author.id)
|
.author_id(msg.author.id)
|
||||||
.filter(move |r| r.emoji == emoji)
|
.filter(move |r| r.emoji == emoji)
|
||||||
|
|
|
@ -35,7 +35,7 @@ impl CacheHttp for CacheAndHttp {
|
||||||
Some(&self.0)
|
Some(&self.0)
|
||||||
}
|
}
|
||||||
fn http(&self) -> &Http {
|
fn http(&self) -> &Http {
|
||||||
&*self.1
|
&self.1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue