cargo clippy --fix
This commit is contained in:
parent
5702c60fc0
commit
4acff7051d
3 changed files with 16 additions and 16 deletions
|
@ -41,7 +41,7 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
|
|||
match ctx {
|
||||
Context::Application(_) => ctx.defer_ephemeral().await?,
|
||||
Context::Prefix(ctx) => {
|
||||
if ctx.msg.attachments.len() == 0 {
|
||||
if ctx.msg.attachments.is_empty() {
|
||||
ctx.msg
|
||||
.reply(
|
||||
&ctx.serenity_context.http,
|
||||
|
@ -99,7 +99,7 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
|
|||
let author = ctx.author();
|
||||
let mut submitted_images = Vec::new();
|
||||
for submission in submission_data.iter_mut() {
|
||||
if is_matching_submission(&submission, author) {
|
||||
if is_matching_submission(submission, author) {
|
||||
existing_submitter = true;
|
||||
let mut images: Vec<String> = submission["images"]
|
||||
.as_array_mut()
|
||||
|
@ -137,7 +137,7 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
|
|||
},
|
||||
extension
|
||||
);
|
||||
images.push(file_name.clone().into());
|
||||
images.push(file_name.clone());
|
||||
let image = reqwest::get(&attachment.url).await?.bytes().await?;
|
||||
let mut image_file =
|
||||
File::create(format!("{}/{}", submission_images_dir, file_name))?;
|
||||
|
@ -185,7 +185,7 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
|
|||
},
|
||||
extension
|
||||
);
|
||||
images.push(file_name.clone().into());
|
||||
images.push(file_name.clone());
|
||||
let image = reqwest::get(&attachment.url).await?.bytes().await?;
|
||||
let mut image_file = File::create(format!("{}/{}", submission_images_dir, file_name))?;
|
||||
image_file.write_all(&image)?;
|
||||
|
@ -275,7 +275,7 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
|
|||
e.description(description);
|
||||
let mut embed_author = serenity::builder::CreateEmbedAuthor::default();
|
||||
embed_author
|
||||
.icon_url(get_avatar(&author))
|
||||
.icon_url(get_avatar(author))
|
||||
.name(username)
|
||||
.url(format!("https://discord.com/users/{}", author.id));
|
||||
e.set_author(embed_author);
|
||||
|
@ -311,7 +311,7 @@ pub async fn images(ctx: Context<'_>) -> Result<(), Error> {
|
|||
let images: Vec<String> = {
|
||||
let mut images = Vec::new();
|
||||
for submission in submission_data.iter() {
|
||||
if is_matching_submission(&submission, &ctx.author()) {
|
||||
if is_matching_submission(submission, ctx.author()) {
|
||||
for image in submission["images"].as_array().unwrap().iter() {
|
||||
images.push(String::from(image.as_str().unwrap()));
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ pub async fn images(ctx: Context<'_>) -> Result<(), Error> {
|
|||
images
|
||||
};
|
||||
let challenge_number = get_challenge_number();
|
||||
if images.len() == 0 {
|
||||
if images.is_empty() {
|
||||
ctx.say(format!(
|
||||
"You haven't submitted anything for Tegaki Tuesday #{}.",
|
||||
challenge_number
|
||||
|
@ -329,10 +329,10 @@ pub async fn images(ctx: Context<'_>) -> Result<(), Error> {
|
|||
.await?;
|
||||
return Ok(());
|
||||
}
|
||||
let mut message = String::from(format!(
|
||||
let mut message = format!(
|
||||
"Your submission images for Tegaki Tuesday #{}:\n",
|
||||
challenge_number
|
||||
));
|
||||
);
|
||||
for (i, image) in images.iter().enumerate() {
|
||||
message.push_str(&format!(
|
||||
"({})<https://{domain}/{}/{}>\n",
|
||||
|
@ -368,7 +368,7 @@ pub async fn imagedelete(ctx: Context<'_>, number: i32) -> Result<(), Error> {
|
|||
let challenge_number = get_challenge_number();
|
||||
let mut submission_data = get_current_submission_data();
|
||||
for (i, submission) in submission_data.iter_mut().enumerate() {
|
||||
if !is_matching_submission(&submission, &ctx.author()) {
|
||||
if !is_matching_submission(submission, ctx.author()) {
|
||||
continue;
|
||||
}
|
||||
let mut images = submission["images"].as_array().unwrap().clone();
|
||||
|
@ -402,7 +402,7 @@ pub async fn imagedelete(ctx: Context<'_>, number: i32) -> Result<(), Error> {
|
|||
Err(ref e) if e.kind() == std::io::ErrorKind::NotFound => (),
|
||||
Err(_) => panic!("Failed to remove file"),
|
||||
};
|
||||
let mut message = String::from(format!("Deleted **{}** from your submission.", image));
|
||||
let mut message = format!("Deleted **{}** from your submission.", image);
|
||||
if images.len() == 1 {
|
||||
message.push_str(" As there are no more images left attached to your submission, it has been deleted.");
|
||||
submission_data.remove(i);
|
||||
|
@ -470,7 +470,7 @@ pub async fn suggest(
|
|||
});
|
||||
let mut embed_author = serenity::builder::CreateEmbedAuthor::default();
|
||||
embed_author
|
||||
.icon_url(get_avatar(&author))
|
||||
.icon_url(get_avatar(author))
|
||||
.name(username)
|
||||
.url(format!("https://discord.com/users/{}", author.id));
|
||||
e.set_author(embed_author);
|
||||
|
|
|
@ -21,7 +21,7 @@ pub async fn i(
|
|||
}
|
||||
let kanji_info = get_kanji_info(character);
|
||||
covered_chars.push(character);
|
||||
if kanji_info.len() == 0 {
|
||||
if kanji_info.is_empty() {
|
||||
skipped_chars += 1;
|
||||
continue;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ pub async fn i(
|
|||
message = format!(
|
||||
"Found {} kanji{}\n{}",
|
||||
found_chars.len(),
|
||||
if found_chars.len() == 0 { "." } else { ":" },
|
||||
if found_chars.is_empty() { "." } else { ":" },
|
||||
message
|
||||
);
|
||||
if skipped_chars > 0 {
|
||||
|
|
|
@ -332,11 +332,11 @@ pub async fn random_kanji(
|
|||
.choose(&mut rand::thread_rng())
|
||||
.unwrap();
|
||||
let list = subcategories[subcategory_key].as_str().unwrap();
|
||||
let kanji = random_from_string(&list);
|
||||
let kanji = random_from_string(list);
|
||||
display_kanji(ctx, kanji, &format!(", **{}**", subcategory_key)).await?;
|
||||
} else if subcategories.contains_key(&subcategory) {
|
||||
let list = list[&subcategory].as_str().unwrap();
|
||||
let kanji = random_from_string(&list);
|
||||
let kanji = random_from_string(list);
|
||||
display_kanji(ctx, kanji, "").await?;
|
||||
} else {
|
||||
let message = format!(
|
||||
|
|
Loading…
Add table
Reference in a new issue