aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
authorNathan Perry <np@nathanperry.dev>2024-08-16 01:46:17 -0400
committerNathan Perry <np@nathanperry.dev>2024-08-16 01:46:17 -0400
commitf39b1607b54073646b8ebae8852000706db885ad (patch)
tree8033b4460593fb729f6aecc1c7deba84d952f3f0 /src/commands
parenta435a926689b0b597caa1c724a91694f74dec778 (diff)
fix required command options
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/meme/create.rs16
-rw-r--r--src/commands/mod.rs3
-rw-r--r--src/commands/playback.rs3
-rw-r--r--src/commands/today/mod.rs34
4 files changed, 24 insertions, 32 deletions
diff --git a/src/commands/meme/create.rs b/src/commands/meme/create.rs
index e2eacbf..c28f583 100644
--- a/src/commands/meme/create.rs
+++ b/src/commands/meme/create.rs
@@ -33,14 +33,8 @@ use crate::{
pub async fn addmeme(
ctx: PoiseContext<'_>,
title: String,
- #[rest] text: String,
+ #[rest] text: Option<String>,
) -> anyhow::Result<()> {
- let text = if text.is_empty() {
- None
- } else {
- Some(text)
- };
-
let mut conn = connection().await?;
let image = util::msg(ctx).and_then(|msg| msg.attachments.first());
@@ -101,7 +95,7 @@ pub async fn addaudiomeme(
ctx: PoiseContext<'_>,
title: String,
audio_str: String,
- #[rest] rest: String,
+ #[rest] text: Option<String>,
) -> anyhow::Result<()> {
debug!("running addaudiomeme");
@@ -155,12 +149,6 @@ pub async fn addaudiomeme(
let mut audio_reader = ffmpeg_command.stdout.unwrap();
- let text = if rest.is_empty() {
- None
- } else {
- Some(rest)
- };
-
let mut conn = connection().await?;
let image_att =
diff --git a/src/commands/mod.rs b/src/commands/mod.rs
index 1ad4a59..b7a8378 100644
--- a/src/commands/mod.rs
+++ b/src/commands/mod.rs
@@ -20,7 +20,8 @@ pub(crate) mod today;
pub use self::meme::*;
pub fn commands() -> Vec<poise::Command<crate::PoiseData, anyhow::Error>> {
- let mut commands = vec![sound_levels::mute(), sound_levels::unmute(), roll::roll(), help()];
+ let mut commands =
+ vec![sound_levels::mute(), sound_levels::unmute(), roll::roll(), today::today(), help()];
commands.extend(playback::commands());
diff --git a/src/commands/playback.rs b/src/commands/playback.rs
index 48f3286..70dd704 100644
--- a/src/commands/playback.rs
+++ b/src/commands/playback.rs
@@ -78,7 +78,8 @@ pub async fn _play(ctx: PoiseContext<'_>, url: &url::Url) -> anyhow::Result<()>
data.get::<HttpKey>().unwrap().clone()
};
- let input = YoutubeDl::new_ytdl_like("yt-dlp", client.clone(), url.to_string());
+ let input =
+ YoutubeDl::new_ytdl_like(&crate::config::YTDL_COMMAND, client.clone(), url.to_string());
call.enqueue_input(input.into()).await;
util::react(ctx, ReactionType::Unicode("📣".to_owned())).await?;
diff --git a/src/commands/today/mod.rs b/src/commands/today/mod.rs
index c1a02d5..7b5fe8d 100644
--- a/src/commands/today/mod.rs
+++ b/src/commands/today/mod.rs
@@ -59,29 +59,31 @@ lazy_static! {
}
#[poise::command(slash_command, prefix_command, guild_only)]
-pub async fn today(ctx: PoiseContext<'_>, #[rest] _rest: String) -> anyhow::Result<()> {
+pub async fn today(ctx: PoiseContext<'_>, #[rest] _rest: Option<String>) -> anyhow::Result<()> {
let today = {
#[allow(unused_mut)]
let mut result = chrono::Local::now().naive_local();
#[cfg(debug_assertions)]
{
- let dt = _rest.parse::<chrono::NaiveDateTime>().or_else(|_| {
- _rest.parse::<chrono::NaiveDate>().map(|date| {
- let time = chrono::NaiveTime::from_hms_opt(12, 0, 0).unwrap();
- date.and_time(time)
- })
- });
+ if let Some(rest) = _rest {
+ let dt = rest.parse::<chrono::NaiveDateTime>().or_else(|_| {
+ rest.parse::<chrono::NaiveDate>().map(|date| {
+ let time = chrono::NaiveTime::from_hms_opt(12, 0, 0).unwrap();
+ date.and_time(time)
+ })
+ });
- match dt {
- Ok(dt) => {
- debug!("overriding with datetime: {dt}");
- result = dt;
- },
- Err(e) => {
- debug!("parsing datetime: {e:?}");
- },
- };
+ match dt {
+ Ok(dt) => {
+ debug!("overriding with datetime: {dt}");
+ result = dt;
+ },
+ Err(e) => {
+ debug!("parsing datetime: {e:?}");
+ },
+ };
+ }
}
result