aboutsummaryrefslogtreecommitdiff
path: root/src/commands/meme
diff options
context:
space:
mode:
authorNathan Perry <np@nathanperry.dev>2024-08-16 02:53:45 -0400
committerNathan Perry <np@nathanperry.dev>2024-08-16 02:53:45 -0400
commitc9e6b2e681088687f5a714c3324d4d0731b8393e (patch)
treeaaded1a3182b2d2ad1268043ad20067b26cb4531 /src/commands/meme
parentf39b1607b54073646b8ebae8852000706db885ad (diff)
better unrecognized handling, more expressive react/unreact indicators
Diffstat (limited to 'src/commands/meme')
-rw-r--r--src/commands/meme/create.rs9
-rw-r--r--src/commands/meme/invoke.rs7
-rw-r--r--src/commands/meme/mod.rs2
3 files changed, 12 insertions, 6 deletions
diff --git a/src/commands/meme/create.rs b/src/commands/meme/create.rs
index c28f583..185e1f6 100644
--- a/src/commands/meme/create.rs
+++ b/src/commands/meme/create.rs
@@ -68,7 +68,7 @@ pub async fn addmeme(
use diesel::result::DatabaseErrorKind;
match save_result {
Ok(_) => {
- util::react(ctx, ReactionType::Unicode("👌".to_string())).await?;
+ util::react(ctx, '👌').await?;
},
Err(e) => {
if let Some(DieselError::DatabaseError(DatabaseErrorKind::UniqueViolation, _)) =
@@ -76,7 +76,7 @@ pub async fn addmeme(
{
error!("tried to create meme that already exists");
- util::react(ctx, ReactionType::Unicode("❌".to_owned())).await?;
+ util::react(ctx, '❌').await?;
util::reply(ctx, "that meme already exists").await?;
return Ok(());
@@ -110,6 +110,8 @@ pub async fn addaudiomeme(
let opts = elems[1..].join(" ");
let (start, end) = parse_times(opts);
+ util::react(ctx, '🔃').await?;
+
let youtube_url = util::ytdl_url(audio_link.as_str()).await?;
debug!("got download url: {youtube_url}");
@@ -169,6 +171,7 @@ pub async fn addaudiomeme(
if bytes == 0 {
debug!("read 0 bytes from audio reader");
+ util::unreact(ctx, '🔃').await?;
util::reply(ctx, "🔇🔇🔇🔕🔕🔕🔕🔕🔇🔕🔕🔇🔕🔕📣📢📣📢📣").await?;
return Ok(());
}
@@ -186,6 +189,8 @@ pub async fn addaudiomeme(
.await
.map(|_| {});
+ util::unreact(ctx, '🔃').await?;
+
use diesel::result::DatabaseErrorKind;
match save_result {
Ok(_) => {
diff --git a/src/commands/meme/invoke.rs b/src/commands/meme/invoke.rs
index 31b0085..1d9040d 100644
--- a/src/commands/meme/invoke.rs
+++ b/src/commands/meme/invoke.rs
@@ -60,14 +60,15 @@ pub async fn silent_meme(ctx: PoiseContext<'_>) -> anyhow::Result<()> {
_meme(ctx, "", AudioPlayback::Prohibited).await
}
-#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
-enum AudioPlayback {
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Default)]
+pub(crate) enum AudioPlayback {
Required,
+ #[default]
Optional,
Prohibited,
}
-async fn _meme(
+pub(crate) async fn _meme(
ctx: PoiseContext<'_>,
args: impl AsRef<str>,
audio_playback: AudioPlayback,
diff --git a/src/commands/meme/mod.rs b/src/commands/meme/mod.rs
index 9495ec7..ca7714a 100644
--- a/src/commands/meme/mod.rs
+++ b/src/commands/meme/mod.rs
@@ -40,7 +40,7 @@ use crate::{
mod create;
mod delete;
mod history;
-mod invoke;
+pub(crate) mod invoke;
pub fn commands() -> Vec<poise::Command<crate::PoiseData, anyhow::Error>> {
vec![