aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/meme/create.rs8
-rw-r--r--src/commands/meme/history.rs14
-rw-r--r--src/commands/meme/mod.rs4
3 files changed, 15 insertions, 11 deletions
diff --git a/src/commands/meme/create.rs b/src/commands/meme/create.rs
index 2cd9465..160de7b 100644
--- a/src/commands/meme/create.rs
+++ b/src/commands/meme/create.rs
@@ -72,7 +72,7 @@ pub async fn addmeme(ctx: &Context, msg: &Message, args: Args) -> CommandResult
if let Some(att) = image {
let data = att.download().await?;
- image_id = Some(Image::create(&mut conn, &att.filename, data, msg.author.id.get())?);
+ image_id = Some(Image::create(&mut conn, &att.filename, data, msg.author.id.get()).await?);
};
let save_result = NewMeme {
@@ -83,6 +83,7 @@ pub async fn addmeme(ctx: &Context, msg: &Message, args: Args) -> CommandResult
metadata_id: 0,
}
.save(&mut conn, msg.author.id.get())
+ .await
.map(|_| {});
use diesel::result::DatabaseErrorKind;
@@ -182,7 +183,7 @@ pub async fn addaudiomeme(ctx: &Context, msg: &Message, args: Args) -> CommandRe
if let Ok(att) = image_att {
let data = att.download().await?;
- image_id = Image::create(&mut conn, &att.filename, data, msg.author.id.get())?.pipe(Some);
+ image_id = Image::create(&mut conn, &att.filename, data, msg.author.id.get())?.await.pipe(Some);
}
let mut audio_data = Vec::new();
@@ -196,7 +197,7 @@ pub async fn addaudiomeme(ctx: &Context, msg: &Message, args: Args) -> CommandRe
.await;
}
- let audio_id = Audio::create(&mut conn, audio_data, msg.author.id.get())?;
+ let audio_id = Audio::create(&mut conn, audio_data, msg.author.id.get()).await?;
let save_result = NewMeme {
title,
@@ -206,6 +207,7 @@ pub async fn addaudiomeme(ctx: &Context, msg: &Message, args: Args) -> CommandRe
metadata_id: 0,
}
.save(&mut conn, msg.author.id.get())
+ .await
.map(|_| {});
use diesel::result::DatabaseErrorKind;
diff --git a/src/commands/meme/history.rs b/src/commands/meme/history.rs
index e2953d1..e5b3d33 100644
--- a/src/commands/meme/history.rs
+++ b/src/commands/meme/history.rs
@@ -60,7 +60,7 @@ static CLEAN_DATE_FORMAT: &str = "%b %-e %Y";
pub async fn wat(ctx: &Context, msg: &Message, _: Args) -> CommandResult {
let mut conn = connection()?;
- let record = match InvocationRecord::last(&mut conn) {
+ let record = match InvocationRecord::last(&mut conn).await {
Ok(x) => x,
Err(e) => {
if let Some(NotFound) = e.downcast_ref::<DieselError>() {
@@ -75,11 +75,11 @@ pub async fn wat(ctx: &Context, msg: &Message, _: Args) -> CommandResult {
},
};
- let meme = Meme::find(&mut conn, record.meme_id);
+ let meme = Meme::find(&mut conn, record.meme_id).await;
match meme {
Ok(ref meme) => {
- let metadata = Metadata::find(&mut conn, meme.metadata_id)?;
+ let metadata = Metadata::find(&mut conn, meme.metadata_id).await?;
let author = CONFIG.discord.guild().member(&ctx, metadata.created_by as u64).await?;
util::send(
@@ -125,7 +125,7 @@ pub async fn history(ctx: &Context, msg: &Message, mut args: Args) -> CommandRes
let records = {
let mut conn = connection()?;
- InvocationRecord::last_n(&mut conn, n)?
+ InvocationRecord::last_n(&mut conn, n).await?
};
if records.is_empty() {
@@ -150,7 +150,9 @@ pub async fn history(ctx: &Context, msg: &Message, mut args: Args) -> CommandRes
""
};
- let meme = Meme::find(&mut conn, rec.meme_id).and_then(|meme| {
+ let meme = Meme::find(&mut conn, rec.meme_id).await;
+
+ .and_then(|meme| {
Metadata::find(&mut conn, meme.metadata_id).map(|metadata| (metadata, meme))
});
@@ -214,7 +216,7 @@ pub async fn stats(ctx: &Context, msg: &Message, _: Args) -> CommandResult {
};
let mut conn = connection()?;
- let stats = db::stats(&mut conn)?;
+ let stats = db::stats(&mut conn).await?;
debug!("reporting stats");
diff --git a/src/commands/meme/mod.rs b/src/commands/meme/mod.rs
index c40e80a..b5a3c98 100644
--- a/src/commands/meme/mod.rs
+++ b/src/commands/meme/mod.rs
@@ -1,4 +1,4 @@
-use diesel::PgConnection;
+use diesel_async::AsyncPgConnection;
use log::debug;
use rand::random;
use serenity::{
@@ -70,7 +70,7 @@ struct Memes;
async fn send_meme(
ctx: &Context,
t: &Meme,
- conn: &mut PgConnection,
+ conn: &mut AsyncPgConnection,
msg: &Message,
) -> CommandResult {
let should_tts =