reply
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use std::str::from_utf8;
|
||||
|
||||
use postcard::to_stdvec;
|
||||
use serenity::{
|
||||
all::{
|
||||
@@ -6,6 +8,7 @@ use serenity::{
|
||||
CreateCommandOption,
|
||||
CreateInteractionResponse,
|
||||
CreateInteractionResponseMessage,
|
||||
EditInteractionResponse,
|
||||
},
|
||||
builder::CreateCommand,
|
||||
model::application::{CommandOptionType, ResolvedOption, ResolvedValue},
|
||||
@@ -27,7 +30,17 @@ pub async fn run(
|
||||
..
|
||||
}) = options.first()
|
||||
{
|
||||
let job = &Job {
|
||||
interaction
|
||||
.create_response(
|
||||
ctx,
|
||||
CreateInteractionResponse::Message(
|
||||
CreateInteractionResponseMessage::new()
|
||||
.content(format!("Searching: {value}...")),
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
|
||||
let job = Job {
|
||||
uuid: new_uuid_v4(),
|
||||
kind: JobKind::Download,
|
||||
inner: InnerStruct {
|
||||
@@ -37,19 +50,21 @@ pub async fn run(
|
||||
|
||||
println!("job {:?}", job);
|
||||
|
||||
if let Err(_why) = nats_client
|
||||
.publish("corro-dj.download", to_stdvec(job).unwrap().into())
|
||||
let response = match nats_client
|
||||
.request("corro-dj.download", to_stdvec(&job).unwrap().into())
|
||||
.await
|
||||
{
|
||||
return Err(serenity::Error::Other("send error"));
|
||||
}
|
||||
Ok(resp) => resp,
|
||||
Err(_why) => return Err(serenity::Error::Other("send error")),
|
||||
};
|
||||
|
||||
println!("response: {:?}", from_utf8(&response.payload).unwrap());
|
||||
|
||||
interaction
|
||||
.create_response(
|
||||
.edit_response(
|
||||
ctx,
|
||||
CreateInteractionResponse::Message(
|
||||
CreateInteractionResponseMessage::new().content(format!("Sent: {value}")),
|
||||
),
|
||||
EditInteractionResponse::new()
|
||||
.content(format!("path: {}", from_utf8(&response.payload).unwrap())),
|
||||
)
|
||||
.await?;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user