aboutsummaryrefslogtreecommitdiff
path: root/src/commands/meme
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/meme')
-rw-r--r--src/commands/meme/create.rs20
-rw-r--r--src/commands/meme/delete.rs4
-rw-r--r--src/commands/meme/history.rs25
-rw-r--r--src/commands/meme/invoke.rs8
-rw-r--r--src/commands/meme/mod.rs4
5 files changed, 28 insertions, 33 deletions
diff --git a/src/commands/meme/create.rs b/src/commands/meme/create.rs
index 185e1f6..a4e9656 100644
--- a/src/commands/meme/create.rs
+++ b/src/commands/meme/create.rs
@@ -2,11 +2,7 @@ use std::process::Stdio;
use anyhow::anyhow;
use diesel::result::Error as DieselError;
-use log::{
- debug,
- error,
- warn,
-};
+use grate::tracing;
use serenity::all::ReactionType;
use tap::Pipe;
use tokio::{
@@ -40,7 +36,7 @@ pub async fn addmeme(
let image = util::msg(ctx).and_then(|msg| msg.attachments.first());
if image.is_none() && text.is_none() {
- warn!("tried to create non-audio meme with no image or text");
+ tracing::warn!("tried to create non-audio meme with no image or text");
util::reply(ctx, "hahAA it's empty xdddd").await?;
return Ok(());
@@ -74,7 +70,7 @@ pub async fn addmeme(
if let Some(DieselError::DatabaseError(DatabaseErrorKind::UniqueViolation, _)) =
e.downcast_ref::<DieselError>()
{
- error!("tried to create meme that already exists");
+ tracing::error!("tried to create meme that already exists");
util::react(ctx, '❌').await?;
util::reply(ctx, "that meme already exists").await?;
@@ -97,7 +93,7 @@ pub async fn addaudiomeme(
audio_str: String,
#[rest] text: Option<String>,
) -> anyhow::Result<()> {
- debug!("running addaudiomeme");
+ tracing::debug!("running addaudiomeme");
let elems = audio_str.split_whitespace().collect::<Vec<_>>();
@@ -113,7 +109,7 @@ pub async fn addaudiomeme(
util::react(ctx, '🔃').await?;
let youtube_url = util::ytdl_url(audio_link.as_str()).await?;
- debug!("got download url: {youtube_url}");
+ tracing::debug!("got download url: {youtube_url}");
let duration_opts = if let Some(e) = end {
vec![
@@ -166,10 +162,10 @@ pub async fn addaudiomeme(
let mut audio_data = Vec::new();
let bytes = audio_reader.read_to_end(&mut audio_data).await?;
- debug!("downloaded audio ({} bytes)", audio_data.len());
+ tracing::debug!("downloaded audio ({} bytes)", audio_data.len());
if bytes == 0 {
- debug!("read 0 bytes from audio reader");
+ tracing::debug!("read 0 bytes from audio reader");
util::unreact(ctx, '🔃').await?;
util::reply(ctx, "🔇🔇🔇🔕🔕🔕🔕🔕🔇🔕🔕🔇🔕🔕📣📢📣📢📣").await?;
@@ -200,7 +196,7 @@ pub async fn addaudiomeme(
if let Some(DieselError::DatabaseError(DatabaseErrorKind::UniqueViolation, _)) =
e.downcast_ref::<DieselError>()
{
- error!("tried to create meme that already exists");
+ tracing::error!("tried to create meme that already exists");
util::react(ctx, ReactionType::Unicode("❌".to_owned())).await?;
util::reply(ctx, "that meme already exists").await?;
diff --git a/src/commands/meme/delete.rs b/src/commands/meme/delete.rs
index 4769cc8..560da28 100644
--- a/src/commands/meme/delete.rs
+++ b/src/commands/meme/delete.rs
@@ -2,7 +2,7 @@ use diesel::{
result::Error as DieselError,
NotFound,
};
-use log::info;
+use grate::tracing;
use serenity::all::ReactionType;
use crate::{
@@ -26,7 +26,7 @@ pub async fn delmeme(ctx: PoiseContext<'_>, title: String) -> anyhow::Result<()>
},
Err(e) => {
if let Some(NotFound) = e.downcast_ref::<DieselError>() {
- info!("attempted to delete nonexistent meme: '{}'", title);
+ tracing::info!("attempted to delete nonexistent meme: '{}'", title);
util::react(ctx, ReactionType::Unicode("❓".to_owned())).await?;
util::reply(ctx, "nice try").await?;
diff --git a/src/commands/meme/history.rs b/src/commands/meme/history.rs
index 68416e5..e3d0de3 100644
--- a/src/commands/meme/history.rs
+++ b/src/commands/meme/history.rs
@@ -3,13 +3,9 @@ use diesel::{
result::Error as DieselError,
NotFound,
};
+use grate::tracing;
use itertools::Itertools;
use lazy_static::lazy_static;
-use log::{
- debug,
- error,
- info,
-};
use serenity::{
futures::{
StreamExt,
@@ -58,7 +54,7 @@ pub async fn wat(ctx: PoiseContext<'_>) -> anyhow::Result<()> {
Ok(x) => x,
Err(e) => {
if let Some(NotFound) = e.downcast_ref::<DieselError>() {
- info!("found no memes in history");
+ tracing::info!("found no memes in history");
util::reply(ctx, "no one has ever memed before").await?;
return Ok(());
@@ -89,7 +85,7 @@ pub async fn wat(ctx: PoiseContext<'_>) -> anyhow::Result<()> {
},
Err(e) => {
if let Some(NotFound) = e.downcast_ref::<DieselError>() {
- info!("last meme not found in database");
+ tracing::info!("last meme not found in database");
util::reply(ctx, "heuueueeeeh?").await?;
return Ok(());
@@ -110,7 +106,10 @@ pub async fn history(ctx: PoiseContext<'_>, n: Option<usize>) -> anyhow::Result<
let n = n.unwrap_or(CONFIG.default_hist);
if n > CONFIG.max_hist {
- debug!("user requested more than MAX_HIST ({}) items from history", CONFIG.max_hist);
+ tracing::debug!(
+ "user requested more than MAX_HIST ({}) items from history",
+ CONFIG.max_hist
+ );
util::reply(ctx, "YER PUSHIN ME OVER THE FUCKIN LINE").await?;
}
@@ -122,13 +121,13 @@ pub async fn history(ctx: PoiseContext<'_>, n: Option<usize>) -> anyhow::Result<
};
if records.is_empty() {
- info!("no memes in history");
+ tracing::info!("no memes in history");
util::reply(ctx, "i don't remember anything :(").await?;
return Ok(());
}
- info!("reporting meme history (len {})", n);
+ tracing::info!("reporting meme history (len {})", n);
let resp = serenity::futures::stream::iter(records.into_iter().enumerate().rev())
.then(|(i, rec)| async move {
@@ -182,7 +181,7 @@ pub async fn history(ctx: PoiseContext<'_>, n: Option<usize>) -> anyhow::Result<
Err(e) => {
if let Some(variant) = e.downcast_ref::<DieselError>() {
if *variant != NotFound {
- error!("error encountered loading meme history: {}", e);
+ tracing::error!("error encountered loading meme history: {}", e);
}
}
@@ -213,7 +212,7 @@ pub async fn stats(ctx: PoiseContext<'_>) -> anyhow::Result<()> {
let mut conn = connection().await?;
let stats = db::stats(&mut conn).await?;
- debug!("reporting stats");
+ tracing::debug!("reporting stats");
let rand_user: User = UserId::new(stats.most_random_meme_user).to_user(&ctx).await?;
let direct_user: User = UserId::new(stats.most_directly_named_meme_user).to_user(&ctx).await?;
@@ -408,7 +407,7 @@ pub async fn query(ctx: PoiseContext<'_>, rest: util::RestVec) -> anyhow::Result
.join("\n");
if result.is_empty() {
- info!("no memes matched query");
+ tracing::info!("no memes matched query");
util::reply(ctx, "no match").await?;
return Ok(());
diff --git a/src/commands/meme/invoke.rs b/src/commands/meme/invoke.rs
index 1d9040d..37a78f5 100644
--- a/src/commands/meme/invoke.rs
+++ b/src/commands/meme/invoke.rs
@@ -2,7 +2,7 @@ use diesel::{
result::Error as DieselError,
NotFound,
};
-use log::info;
+use grate::tracing;
use crate::{
commands::meme::send_meme,
@@ -89,7 +89,7 @@ pub(crate) async fn _meme(
},
Err(e) => {
return if let Some(NotFound) = e.downcast_ref::<DieselError>() {
- info!("requested meme not found in database");
+ tracing::info!("requested meme not found in database");
util::reply(ctx, "c'mon baby, guesstimate").await?;
Ok(())
@@ -123,7 +123,7 @@ async fn rand_meme(ctx: PoiseContext<'_>, audio_playback: AudioPlayback) -> anyh
},
Err(e) => {
if let Some(NotFound) = e.downcast_ref::<DieselError>() {
- info!("random meme not found");
+ tracing::info!("random meme not found");
util::reply(ctx, "i don't know any :(").await?;
return Ok(());
@@ -151,7 +151,7 @@ pub async fn rare_meme(ctx: PoiseContext<'_>) -> anyhow::Result<()> {
},
Err(e) => {
if let Some(NotFound) = e.downcast_ref::<DieselError>() {
- info!("rare meme not found");
+ tracing::info!("rare meme not found");
util::reply(ctx, "i don't know any :(").await?;
return Ok(());
diff --git a/src/commands/meme/mod.rs b/src/commands/meme/mod.rs
index ca7714a..4819c1d 100644
--- a/src/commands/meme/mod.rs
+++ b/src/commands/meme/mod.rs
@@ -1,5 +1,5 @@
use diesel_async::AsyncPgConnection;
-use log::debug;
+use grate::tracing;
use rand::random;
use serenity::{
all::ReactionType,
@@ -70,7 +70,7 @@ async fn send_meme(
let should_tts =
t.content.as_ref().map(|t| !t.is_empty()).unwrap_or(false) && random::<u32>() % 25 == 0;
- debug!("sending meme (tts: {}): {:?}", should_tts, t);
+ tracing::debug!("sending meme (tts: {}): {:?}", should_tts, t);
let image = t.image(conn).await;
let audio = t.audio(conn).await;