Files
ohrwurm/src/interaction_commands.rs
Johannes Heuel 4a69e0f578
All checks were successful
tests / build (push) Successful in 1m4s
tests / fmt (push) Successful in 2m17s
tests / clippy (push) Successful in 2m14s
tests / pre-commit (push) Successful in 2m12s
tests / test (push) Successful in 2m27s
deploy / release-image (push) Successful in 6m11s
cleanup
2024-06-19 19:14:44 +02:00

45 lines
1.4 KiB
Rust

use twilight_model::application::interaction::application_command::{
CommandData, CommandOptionValue,
};
#[derive(Debug)]
pub(crate) enum InteractionCommand {
Play(String),
Stop,
Pause,
Skip,
Loop,
Resume,
Leave,
Join,
Queue,
NotImplemented,
}
impl From<Box<CommandData>> for InteractionCommand {
fn from(command: Box<CommandData>) -> InteractionCommand {
match command.name.as_str() {
"play" => {
if let Some(query_option) = command.options.iter().find(|opt| opt.name == "query") {
if let CommandOptionValue::String(query) = &query_option.value {
InteractionCommand::Play(query.clone())
} else {
InteractionCommand::NotImplemented
}
} else {
InteractionCommand::NotImplemented
}
}
"stop" => InteractionCommand::Stop,
"pause" => InteractionCommand::Pause,
"skip" => InteractionCommand::Skip,
"loop" => InteractionCommand::Loop,
"resume" => InteractionCommand::Resume,
"leave" => InteractionCommand::Leave,
"join" => InteractionCommand::Join,
"queue" => InteractionCommand::Queue,
_ => InteractionCommand::NotImplemented,
}
}
}