cleanup
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
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
This commit is contained in:
44
src/interaction_commands.rs
Normal file
44
src/interaction_commands.rs
Normal file
@@ -0,0 +1,44 @@
|
||||
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,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user