song download

This commit is contained in:
2026-02-25 23:48:21 +01:00
parent 5bdf915c4a
commit 5789278b4f
11 changed files with 1500 additions and 54 deletions
+2 -1
View File
@@ -4,6 +4,7 @@ version = "0.1.0"
edition = "2024"
[dependencies]
types = { path = "../types" }
async-nats = { version = "0.46.0" }
serenity = { version = "0.12.5", default-features = false, features = [
"client",
@@ -14,4 +15,4 @@ serenity = { version = "0.12.5", default-features = false, features = [
] }
tokio = { version = "1.49.0", features = ["macros", "rt-multi-thread"] }
postcard = { version = "1.1.3", features = ["use-std"] }
serde = { version = "1.0.228" }
uuid = { version = "1.21.0" }
+14 -23
View File
@@ -6,19 +6,9 @@ use serenity::builder::CreateCommand;
use serenity::model::application::{CommandOptionType, ResolvedOption, ResolvedValue};
use postcard::to_stdvec;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
struct InnerStruct<'a> {
str: &'a str,
}
#[derive(Serialize, Deserialize, Debug)]
struct MyStruct<'a> {
len: usize,
str: &'a str,
inner: InnerStruct<'a>,
}
use types::jobs::{InnerStruct, Job, JobKind};
use types::misc::new_uuid_v4;
pub async fn run(
ctx: &Context,
@@ -32,19 +22,20 @@ pub async fn run(
..
}) = options.first()
{
let hehe = &MyStruct {
len: value.len(),
str: value,
inner: InnerStruct { str: &value.repeat(3) }
let job = &Job {
uuid: new_uuid_v4(),
kind: JobKind::Download,
inner: InnerStruct {
str: value.to_string(),
},
};
println!("{:?}", hehe);
println!("job {:?}", job);
let ahah = to_stdvec(hehe).unwrap();
println!("{:?}", ahah);
if let Err(why) = nats_client.publish("corro-dj.download", ahah.into()).await {
if let Err(_why) = nats_client
.publish("corro-dj.download", to_stdvec(job).unwrap().into())
.await
{
return Err(serenity::Error::Other("send error"));
}
@@ -52,7 +43,7 @@ pub async fn run(
.create_response(
ctx,
CreateInteractionResponse::Message(
CreateInteractionResponseMessage::new().content(*value),
CreateInteractionResponseMessage::new().content(format!("Sent: {value}")),
),
)
.await?;