aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/meme/create.rs12
-rw-r--r--src/commands/meme/history.rs20
-rw-r--r--src/commands/meme/invoke.rs14
-rw-r--r--src/commands/meme/mod.rs16
-rw-r--r--src/commands/mod.rs14
5 files changed, 36 insertions, 40 deletions
diff --git a/src/commands/meme/create.rs b/src/commands/meme/create.rs
index 2d0ee9a..80fbe44 100644
--- a/src/commands/meme/create.rs
+++ b/src/commands/meme/create.rs
@@ -12,16 +12,16 @@ use tokio::{
use url::Url;
use crate::{
+ FFMPEG_COMMAND,
+ PoiseContext,
db::{
- connection,
Audio,
Image,
NewMeme,
+ connection,
},
parse_times,
util,
- PoiseContext,
- FFMPEG_COMMAND,
};
/// Add a text/image meme to the db.
@@ -79,7 +79,7 @@ pub async fn addmeme(
return Ok(());
}
- return Err(e.into());
+ return Err(e);
},
}
@@ -100,7 +100,7 @@ pub async fn addaudiomeme(
if elems.is_empty() {
util::reply(ctx, "are you stupid").await?;
- return Err(anyhow!("no audio link was provided").into());
+ return Err(anyhow!("no audio link was provided"));
}
let audio_link = Url::parse(elems[0])?;
@@ -206,7 +206,7 @@ pub async fn addaudiomeme(
return Ok(());
}
- return Err(e.into());
+ return Err(e);
},
}
diff --git a/src/commands/meme/history.rs b/src/commands/meme/history.rs
index 236e47f..5a46758 100644
--- a/src/commands/meme/history.rs
+++ b/src/commands/meme/history.rs
@@ -4,8 +4,8 @@ use chrono::{
Utc,
};
use diesel::{
- result::Error as DieselError,
NotFound,
+ result::Error as DieselError,
};
use grate::tracing;
use itertools::Itertools;
@@ -33,17 +33,17 @@ use timeago::{
};
use crate::{
+ PoiseContext,
commands::game::get_user_id,
config::CONFIG,
db::{
self,
- connection,
InvocationRecord,
Meme,
Metadata,
+ connection,
},
util,
- PoiseContext,
};
lazy_static! {
@@ -76,7 +76,7 @@ pub async fn wat(ctx: PoiseContext<'_>) -> anyhow::Result<()> {
}
util::reply(ctx, "BAD MEME BAD MEME").await?;
- return Err(e.into());
+ return Err(e);
},
};
@@ -107,7 +107,7 @@ pub async fn wat(ctx: PoiseContext<'_>) -> anyhow::Result<()> {
}
util::reply(ctx, "do i look like i know what a jpeg is").await?;
- return Err(e.into());
+ return Err(e);
},
};
@@ -151,7 +151,7 @@ pub async fn history(ctx: PoiseContext<'_>, n: Option<usize>) -> anyhow::Result<
.then(|(i, rec)| async move {
let mut conn = connection().await?;
- let dt = chrono::Utc.from_utc_datetime(&rec.time).conv::<Timestamp>();
+ let dt = Utc.from_utc_datetime(&rec.time).conv::<Timestamp>();
let ago = FormattedTimestamp::new(dt, Some(FormattedTimestampStyle::RelativeTime));
let rand = if rec.random {
@@ -186,10 +186,10 @@ pub async fn history(ctx: PoiseContext<'_>, n: Option<usize>) -> anyhow::Result<
)
},
Err(e) => {
- if let Some(variant) = e.downcast_ref::<DieselError>() {
- if *variant != NotFound {
- tracing::error!(error = %e, "error encountered loading meme history");
- }
+ if let Some(variant) = e.downcast_ref::<DieselError>()
+ && *variant != NotFound
+ {
+ tracing::error!(error = %e, "error encountered loading meme history");
}
format!(
diff --git a/src/commands/meme/invoke.rs b/src/commands/meme/invoke.rs
index d7c6b3f..f057db5 100644
--- a/src/commands/meme/invoke.rs
+++ b/src/commands/meme/invoke.rs
@@ -1,20 +1,20 @@
use diesel::{
- result::Error as DieselError,
NotFound,
+ result::Error as DieselError,
};
use grate::tracing;
use crate::{
+ PoiseContext,
+ RestVec,
commands::meme::send_meme,
db::{
self,
+ InvocationRecord,
connection,
find_meme,
- InvocationRecord,
},
util,
- PoiseContext,
- RestVec,
};
/// Post a meme.
@@ -104,7 +104,7 @@ pub(crate) async fn _meme(
Ok(())
} else {
util::reply(ctx, "what in ryan's name").await?;
- Err(e.into())
+ Err(e)
};
},
};
@@ -152,7 +152,7 @@ async fn rand_meme(ctx: PoiseContext<'_>, audio_playback: AudioPlayback) -> anyh
}
util::reply(ctx, "HELP").await?;
- Err(e.into())
+ Err(e)
},
}
}
@@ -197,7 +197,7 @@ pub async fn rare_meme(ctx: PoiseContext<'_>) -> anyhow::Result<()> {
util::reply(ctx, "THE MEME MARKET IS IN FREEFALL").await?;
- Err(e.into())
+ Err(e)
},
}
}
diff --git a/src/commands/meme/mod.rs b/src/commands/meme/mod.rs
index 603ec28..98cabef 100644
--- a/src/commands/meme/mod.rs
+++ b/src/commands/meme/mod.rs
@@ -15,14 +15,14 @@ use serenity::{
},
};
use songbird::input::{
- core::{
- io::MediaSource,
- probe::Hint,
- },
AudioStream,
AudioStreamError,
Compose,
Input,
+ core::{
+ io::MediaSource,
+ probe::Hint,
+ },
};
pub use self::{
@@ -32,12 +32,13 @@ pub use self::{
invoke::*,
};
use crate::{
+ PoiseContext,
bot::PlaybackKey,
commands::{
playback,
playback::{
- songbird,
InvokeInfo,
+ songbird,
},
},
db::{
@@ -45,7 +46,6 @@ use crate::{
Meme,
},
util,
- PoiseContext,
};
mod create;
@@ -78,8 +78,8 @@ async fn send_meme(
t: &Meme,
conn: &mut AsyncPgConnection,
) -> anyhow::Result<()> {
- let should_tts =
- t.content.as_ref().map(|t| !t.is_empty()).unwrap_or(false) && random::<u32>() % 25 == 0;
+ let should_tts = t.content.as_ref().map(|t| !t.is_empty()).unwrap_or(false)
+ && random::<u32>().is_multiple_of(25);
tracing::debug!(should_tts, meme = ?t, "sending meme");
diff --git a/src/commands/mod.rs b/src/commands/mod.rs
index b0ef83b..a5ee1bd 100644
--- a/src/commands/mod.rs
+++ b/src/commands/mod.rs
@@ -1,8 +1,8 @@
use poise::builtins::PrettyHelpConfiguration;
use crate::{
- commands::playback::_play,
PoiseContext,
+ commands::playback::_play,
};
#[cfg(feature = "games")]
@@ -42,20 +42,16 @@ pub fn commands() -> Vec<poise::Command<crate::PoiseData, anyhow::Error>> {
/// Print this help text.
#[poise::command(prefix_command, aliases("halp"))]
pub async fn help(ctx: PoiseContext<'_>, command: Option<String>) -> anyhow::Result<()> {
- poise::builtins::pretty_help(
- ctx,
- command.as_ref().map(|x| x.as_str()),
- PrettyHelpConfiguration {
- ..Default::default()
- },
- )
+ poise::builtins::pretty_help(ctx, command.as_deref(), PrettyHelpConfiguration {
+ ..Default::default()
+ })
.await?;
Ok(())
}
pub async fn link_unrecognized(ctx: PoiseContext<'_>, u: url::Url) -> anyhow::Result<()> {
- let _ = _play(ctx, &u).await?;
+ _play(ctx, &u).await?;
Ok(())
}