aboutsummaryrefslogtreecommitdiff
path: root/src/commands/meme/history.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/meme/history.rs')
-rw-r--r--src/commands/meme/history.rs24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/commands/meme/history.rs b/src/commands/meme/history.rs
index e5b3d33..fc95e2d 100644
--- a/src/commands/meme/history.rs
+++ b/src/commands/meme/history.rs
@@ -58,7 +58,7 @@ static CLEAN_DATE_FORMAT: &str = "%b %-e %Y";
#[command]
#[aliases("what", "hwaet", "hwæt")]
pub async fn wat(ctx: &Context, msg: &Message, _: Args) -> CommandResult {
- let mut conn = connection()?;
+ let mut conn = connection().await?;
let record = match InvocationRecord::last(&mut conn).await {
Ok(x) => x,
@@ -124,7 +124,7 @@ pub async fn history(ctx: &Context, msg: &Message, mut args: Args) -> CommandRes
let n = n.min(CONFIG.max_hist);
let records = {
- let mut conn = connection()?;
+ let mut conn = connection().await?;
InvocationRecord::last_n(&mut conn, n).await?
};
@@ -139,7 +139,7 @@ pub async fn history(ctx: &Context, msg: &Message, mut args: Args) -> CommandRes
let resp = serenity::futures::stream::iter(records.into_iter().enumerate().rev())
.then(|(i, rec)| async move {
- let mut conn = connection()?;
+ let mut conn = connection().await?;
let dt = chrono::DateTime::from_utc(rec.time, chrono::Utc {});
let ago = TIME_FORMATTER.convert((chrono::Utc::now() - dt).to_std().unwrap());
@@ -150,11 +150,12 @@ pub async fn history(ctx: &Context, msg: &Message, mut args: Args) -> CommandRes
""
};
- let meme = Meme::find(&mut conn, rec.meme_id).await;
-
- .and_then(|meme| {
- Metadata::find(&mut conn, meme.metadata_id).map(|metadata| (metadata, meme))
- });
+ let meme = match Meme::find(&mut conn, rec.meme_id).await {
+ Ok(meme) => Metadata::find(&mut conn, meme.metadata_id)
+ .await
+ .map(|metadata| (metadata, meme)),
+ Err(e) => Err(e),
+ };
let invoker_name = CONFIG
.discord
@@ -215,7 +216,7 @@ pub async fn stats(ctx: &Context, msg: &Message, _: Args) -> CommandResult {
user::User,
};
- let mut conn = connection()?;
+ let mut conn = connection().await?;
let stats = db::stats(&mut conn).await?;
debug!("reporting stats");
@@ -282,7 +283,8 @@ and *{}* was the most-memed overall ({})"#,
pub async fn memers(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
use serenity::model::id::UserId;
- let s = db::memers()?
+ let s = db::memers()
+ .await?
.into_iter()
.pipe(serenity::futures::stream::iter)
.then(|info| async move {
@@ -361,7 +363,7 @@ pub async fn query(ctx: &Context, msg: &Message, mut args: Args) -> CommandResul
}
};
- let iter = db::query_meme(args.rest(), creator, order)?.into_iter();
+ let iter = db::query_meme(args.rest(), creator, order).await?.into_iter();
let result = iter
.pipe(serenity::futures::stream::iter)