feat(bot): add cheseburger and update error-codes
This commit is contained in:
parent
f1a56d8e26
commit
4eb5c1d5e7
4 changed files with 26 additions and 9 deletions
1
.gitmodules
vendored
1
.gitmodules
vendored
|
|
@ -1,3 +1,4 @@
|
|||
[submodule "error-codes"]
|
||||
path = error-codes
|
||||
url = https://github.com/AToska21/error-codes.git
|
||||
branch = dev
|
||||
|
|
|
|||
23
build.rs
23
build.rs
|
|
@ -24,6 +24,8 @@ struct ErrorInfo{
|
|||
}
|
||||
|
||||
fn main(){
|
||||
println!("cargo:rerun-if-changed=./error-codes");
|
||||
|
||||
let mut code = "pub fn get_error_code_and_category(category: u16, code: u16) -> (super::CategoryInfo, super::ErrorInfo) {\
|
||||
let category_result = match category{\
|
||||
".to_owned();
|
||||
|
|
@ -135,43 +137,50 @@ fn main(){
|
|||
panic!("unable to parse error json");
|
||||
};
|
||||
|
||||
let name = name.replace("\"", "\\\"");
|
||||
let name = name.replace("\"", "\\\"")
|
||||
.replace("\\n", "\n");
|
||||
|
||||
let Value::String(message) = &error["message"] else {
|
||||
panic!("unable to parse error json");
|
||||
};
|
||||
|
||||
let message = message.replace("\"", "\\\"");
|
||||
let message = message.replace("\"", "\\\"")
|
||||
.replace("\\n", "\n");
|
||||
|
||||
let Value::String(short_description) = &error["short_description"] else {
|
||||
panic!("unable to parse error json");
|
||||
};
|
||||
|
||||
let short_description = short_description.replace("\"", "\\\"");
|
||||
let short_description = short_description.replace("\"", "\\\"")
|
||||
.replace("\\n", "\n");
|
||||
|
||||
let Value::String(long_description) = &error["long_description"] else {
|
||||
panic!("unable to parse error json");
|
||||
};
|
||||
|
||||
let long_description = long_description.replace("\"", "\\\"");
|
||||
let long_description = long_description.replace("\"", "\\\"")
|
||||
.replace("\\n", "\n");
|
||||
|
||||
let Value::String(short_solution) = &error["short_solution"] else {
|
||||
panic!("unable to parse error json");
|
||||
};
|
||||
|
||||
let short_solution = short_solution.replace("\"", "\\\"");
|
||||
let short_solution = short_solution.replace("\"", "\\\"")
|
||||
.replace("\\n", "\n");
|
||||
|
||||
let Value::String(long_solution) = &error["long_solution"] else {
|
||||
panic!("unable to parse error json");
|
||||
};
|
||||
|
||||
let long_solution = long_solution.replace("\"", "\\\"");
|
||||
let long_solution = long_solution.replace("\"", "\\\"")
|
||||
.replace("\\n", "\n");
|
||||
|
||||
let Value::String(support_link) = &error["support_link"] else {
|
||||
panic!("unable to parse error json");
|
||||
};
|
||||
|
||||
let support_link = support_link.replace("\"", "\\\"");
|
||||
let support_link = support_link.replace("\"", "\\\"")
|
||||
.replace("\\n", "\n");
|
||||
|
||||
code.write_str(
|
||||
&format!("\
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 2902808d5c80fd8bf6afcf198949c861199b987d
|
||||
Subproject commit 3de15cd5481f815c509cfe606b4f3416589b4a2c
|
||||
|
|
@ -55,6 +55,9 @@ impl Default for ErrorInfo{
|
|||
static ERROR_CODE_REGEX: Lazy<Regex> =
|
||||
Lazy::new(|| Regex::new("\\d\\d\\d-\\d\\d\\d\\d").expect("invalid regex"));
|
||||
|
||||
static CHEESEBURGER_REGEX: Lazy<Regex> =
|
||||
Lazy::new(|| Regex::new("[Cc]heeseburger(s)?").expect("invalid regex"));
|
||||
|
||||
pub struct ErrorCodeHandler;
|
||||
|
||||
fn create_error_explain_message(str_code: &str, expanded: bool) -> Option<EditMessage>{
|
||||
|
|
@ -76,7 +79,7 @@ fn create_error_explain_message(str_code: &str, expanded: bool) -> Option<EditMe
|
|||
.field("System", category_info.system, true)
|
||||
.field("Module Description", category_info.description, true)
|
||||
.field("Name", error_info.name, false)
|
||||
.field("Explanation", error_info.message, true)
|
||||
.field("Explanation", format!("```{}```", error_info.message), true)
|
||||
.field("Description", error_info.long_description, true)
|
||||
.field("Solution", error_info.long_solution, true)
|
||||
;
|
||||
|
|
@ -149,6 +152,10 @@ impl EventHandler for ErrorCodeHandler {
|
|||
|
||||
start_timed_explanation_collapse(msg, ctx.http.clone(), str_code);
|
||||
}
|
||||
|
||||
if CHEESEBURGER_REGEX.is_match(&msg.content){
|
||||
msg.reply(&ctx.http, "currently scratching the FUCK out of my bum bum idgaf").await.ok();
|
||||
}
|
||||
}
|
||||
|
||||
async fn interaction_create(&self, ctx: Context, interaction: Interaction) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue