1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
// #[macro_export]
// macro_rules! command_response {
// use serde::{Serialize, Deserialize};
// use derive_more::Display;
// ($access:expr) => {
// expr type CommandResult = Result<CommandOk, CommandError>;
// }
// #[derive(Serialize, Deserialize, Debug)]
// #[display(fmt = "{}", "serde_json::to_string(self).unwrap()")]
// pub struct CommandOk {
// pub result: String,
// }
// impl Default for CommandOk {
// fn default() -> Self { Self { result: "accepted".to_string() } }
// }
// #[derive(Serialize, Deserialize, Debug, Clone, Builder)]
// #[display(fmt = "{}", "serde_json::to_string(self).unwrap()")]
// #[builder(setter(into, prefix = "with"))]
// pub struct CommandError {
// #[builder(default = "\"bot_disabled\".to_string()")]
// pub reason: String,
// #[builder(default = "HashMap::from_iter( [(\"status_message\".to_string(), serde_json::Value::String(\"please stand by\".to_string()))] )")]
// pub error_data: HashMap<String, serde_json::Value>,
// #[builder(default)]
// pub errors: Vec<String>,
// }
// impl CommandError {
// pub fn with_status_message(mut self, description: String) -> Self {
// self.error_data.insert("status_message".to_string(), serde_json::Value::String(description));
// self
// }
// }
// impl Default for CommandError {
// fn default() -> Self {
// Self {
// reason: "bot_disabled".to_string(),
// error_data: HashMap::from_iter( [("status_message".to_string(), serde_json::Value::String("please stand by".to_string()))] ),
// errors: Default::default()
// }
// }
// }
// }