pub enum Argument {
String(String),
Integer(i32),
Boolean(bool),
User(UserId),
Channel(ChannelId),
Role(RoleId),
}
Expand description
Represents the argument data sent into commands
Variants§
Implementations§
source§impl Argument
impl Argument
sourcepub fn parse(
source: &CommandSource,
tree: &CommandArgumentsTree
) -> Option<(HashMap<String, Self>, CommandFunction)>
pub fn parse(
source: &CommandSource,
tree: &CommandArgumentsTree
) -> Option<(HashMap<String, Self>, CommandFunction)>
Traverses the argument tree of cmd
and outputs a map of arguments and the function to run
sourcepub fn parse_interaction(
interaction: &ApplicationCommandInteraction,
tree: &CommandArgumentsTree
) -> Option<(HashMap<String, Self>, CommandFunction)>
pub fn parse_interaction(
interaction: &ApplicationCommandInteraction,
tree: &CommandArgumentsTree
) -> Option<(HashMap<String, Self>, CommandFunction)>
Parses CommandDataOptions into Argument and gets the function pointer for the node we need to run
sourcepub fn get_arg_strings(str: &str) -> Vec<&str> ⓘ
pub fn get_arg_strings(str: &str) -> Vec<&str> ⓘ
Splits a raw string into argument words respecting quotation marks
let string = r#"this is a string "with quotes in it""#;
let args = Argument::get_arg_strings(string);
assert_eq!(args, vec!["this","is","a","string","with quotes in it"]);
sourcepub fn parse_message(
content: &str,
tree: &CommandArgumentsTree
) -> Option<(HashMap<String, Self>, CommandFunction)>
pub fn parse_message(
content: &str,
tree: &CommandArgumentsTree
) -> Option<(HashMap<String, Self>, CommandFunction)>
Takes a string and traverses the arguments tree to get a argument map and function to run
sourcepub async fn to_pretty_string(&self, cache: &Cache) -> String
pub async fn to_pretty_string(&self, cache: &Cache) -> String
Converts the argument to a string representation, converting ids to names
Trait Implementations§
source§impl PartialEq<Argument> for Argument
impl PartialEq<Argument> for Argument
impl Eq for Argument
impl StructuralEq for Argument
impl StructuralPartialEq for Argument
Auto Trait Implementations§
impl RefUnwindSafe for Argument
impl Send for Argument
impl Sync for Argument
impl Unpin for Argument
impl UnwindSafe for Argument
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.