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.rs23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/commands/meme/history.rs b/src/commands/meme/history.rs
index 8186f57..f9e8851 100644
--- a/src/commands/meme/history.rs
+++ b/src/commands/meme/history.rs
@@ -51,9 +51,9 @@ static CLEAN_DATE_FORMAT: &'static str = "%b %-e %Y";
#[command]
#[aliases("what")]
pub fn wat(ctx: &mut Context, msg: &Message, _: Args) -> Result<()> {
- let conn = connection()?;
+ let mut conn = connection()?;
- let record = match InvocationRecord::last(&conn) {
+ let record = match InvocationRecord::last(&mut conn) {
Ok(x) => x,
Err(e) => {
if let Some(NotFound) = e.downcast_ref::<DieselError>() {
@@ -66,11 +66,11 @@ pub fn wat(ctx: &mut Context, msg: &Message, _: Args) -> Result<()> {
},
};
- let meme = Meme::find(&conn, record.meme_id);
+ let meme = Meme::find(&mut conn, record.meme_id);
match meme {
Ok(ref meme) => {
- let metadata = Metadata::find(&conn, meme.metadata_id)?;
+ let metadata = Metadata::find(&mut conn, meme.metadata_id)?;
let author = CONFIG.discord.guild().member(&ctx, metadata.created_by as u64)?;
ctx.send(msg.channel_id,
@@ -95,7 +95,7 @@ pub fn wat(ctx: &mut Context, msg: &Message, _: Args) -> Result<()> {
pub fn history(ctx: &mut Context, msg: &Message, mut args: Args) -> Result<()> {
use itertools::Itertools;
- let conn = connection()?;
+ let mut conn = connection()?;
let n = args.single_quoted::<usize>().unwrap_or(CONFIG.default_hist);
@@ -106,7 +106,7 @@ pub fn history(ctx: &mut Context, msg: &Message, mut args: Args) -> Result<()> {
let n = n.min(CONFIG.max_hist);
- let records = InvocationRecord::last_n(&conn, n)?;
+ let records = InvocationRecord::last_n(&mut conn, n)?;
if records.len() == 0 {
info!("no memes in history");
@@ -123,9 +123,9 @@ pub fn history(ctx: &mut Context, msg: &Message, mut args: Args) -> Result<()> {
let ago = TIME_FORMATTER.convert((chrono::Utc::now() - dt).to_std().unwrap());
let rand = if rec.random { "R, " } else { "" };
- Meme::find(&conn, rec.meme_id)
+ Meme::find(&mut conn, rec.meme_id)
.and_then(|meme| {
- Metadata::find(&conn, meme.metadata_id).map(|metadata| (metadata, meme))
+ Metadata::find(&mut conn, meme.metadata_id).map(|metadata| (metadata, meme))
})
.map(|(metadata, meme)| {
let author_name = CONFIG.discord.guild().member(&ctx, metadata.created_by as u64).map(|m| m.display_name().into_owned()).unwrap_or("???".to_owned());
@@ -157,8 +157,8 @@ pub fn stats(ctx: &mut Context, msg: &Message, _: Args) -> Result<()> {
user::User,
};
- let conn = connection()?;
- let stats = db::stats(&conn)?;
+ let mut conn = connection()?;
+ let stats = db::stats(&mut conn)?;
debug!("reporting stats");
@@ -332,5 +332,6 @@ pub fn query(ctx: &mut Context, msg: &Message, mut args: Args) -> Result<()> {
return ctx.send(msg.channel_id, "no match".to_owned(), msg.tts);
}
+
ctx.send(msg.channel_id, &result, msg.tts)
-} \ No newline at end of file
+}