aboutsummaryrefslogtreecommitdiff
path: root/src/commands/today/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/today/mod.rs')
-rw-r--r--src/commands/today/mod.rs32
1 files changed, 12 insertions, 20 deletions
diff --git a/src/commands/today/mod.rs b/src/commands/today/mod.rs
index 7f1dca7..c1a02d5 100644
--- a/src/commands/today/mod.rs
+++ b/src/commands/today/mod.rs
@@ -5,22 +5,14 @@ use rand::{
seq::SliceRandom,
thread_rng,
};
-use serenity::{
- framework::standard::{
- macros::command,
- Args,
- CommandResult,
- },
- model::channel::Message,
- prelude::*,
-};
use songbird::input::YoutubeDl;
use tap::Conv;
use crate::{
bot::HttpKey,
- commands::songbird,
+ commands::playback::songbird,
util,
+ PoiseContext,
CONFIG,
};
@@ -66,16 +58,16 @@ lazy_static! {
];
}
-#[command]
-pub async fn today(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
+#[poise::command(slash_command, prefix_command, guild_only)]
+pub async fn today(ctx: PoiseContext<'_>, #[rest] _rest: String) -> anyhow::Result<()> {
let today = {
#[allow(unused_mut)]
let mut result = chrono::Local::now().naive_local();
#[cfg(debug_assertions)]
{
- let dt = _args.parse::<chrono::NaiveDateTime>().or_else(|_| {
- _args.parse::<chrono::NaiveDate>().map(|date| {
+ 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)
})
@@ -83,11 +75,11 @@ pub async fn today(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
match dt {
Ok(dt) => {
- log::debug!("overriding with datetime: {}", dt);
+ debug!("overriding with datetime: {dt}");
result = dt;
},
Err(e) => {
- log::debug!("parsing datetime: {:?}", e);
+ debug!("parsing datetime: {e:?}");
},
};
}
@@ -102,7 +94,7 @@ pub async fn today(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
let play_args = options.choose(&mut thread_rng());
if let Some(play_args) = play_args {
- let (_sb, call) = songbird(ctx, msg).await?;
+ let (_sb, call) = songbird(ctx).await?;
let mut call = call.lock().await;
if call.current_channel().is_none() {
@@ -110,7 +102,7 @@ pub async fn today(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
}
let client = {
- let data = ctx.data.read().await;
+ let data = ctx.serenity_context().data.read().await;
data.get::<HttpKey>().unwrap().clone()
};
@@ -130,8 +122,8 @@ pub async fn today(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
});
q.resume()?;
} else {
- util::send(ctx, msg.channel_id, "no", false).await?;
- util::send(ctx, msg.channel_id, ":angry:", false).await?;
+ util::reply(ctx, "no").await?;
+ util::reply(ctx, ":angry:").await?;
}
Ok(())