This commit is contained in:
parent
2564c154cf
commit
40a576ff0b
3 changed files with 4 additions and 37 deletions
31
build.rs
31
build.rs
|
|
@ -1,28 +1,7 @@
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use std::{env, fs};
|
use std::{env, fs};
|
||||||
use std::fs::FileType;
|
|
||||||
use std::iter::Map;
|
|
||||||
use serde::Deserialize;
|
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
|
||||||
struct CategoryInfo{
|
|
||||||
name: String,
|
|
||||||
description: String,
|
|
||||||
system: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
|
||||||
struct ErrorInfo{
|
|
||||||
name: String,
|
|
||||||
message: String,
|
|
||||||
short_description: String,
|
|
||||||
long_description: String,
|
|
||||||
short_solution: String,
|
|
||||||
long_solution: String,
|
|
||||||
support_link: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main(){
|
fn main(){
|
||||||
println!("cargo:rerun-if-changed=./error-codes");
|
println!("cargo:rerun-if-changed=./error-codes");
|
||||||
|
|
||||||
|
|
@ -173,13 +152,6 @@ fn main(){
|
||||||
let long_solution = long_solution.replace("\"", "\\\"")
|
let long_solution = long_solution.replace("\"", "\\\"")
|
||||||
.replace("\\n", "\n");
|
.replace("\\n", "\n");
|
||||||
|
|
||||||
let Value::String(support_link) = &error["support_link"] else {
|
|
||||||
panic!("unable to parse error json");
|
|
||||||
};
|
|
||||||
|
|
||||||
let support_link = support_link.replace("\"", "\\\"")
|
|
||||||
.replace("\\n", "\n");
|
|
||||||
|
|
||||||
code.write_str(
|
code.write_str(
|
||||||
&format!("\
|
&format!("\
|
||||||
({},{}) => super::ErrorInfo{{\
|
({},{}) => super::ErrorInfo{{\
|
||||||
|
|
@ -189,9 +161,8 @@ fn main(){
|
||||||
long_description: \"{}\",
|
long_description: \"{}\",
|
||||||
short_solution: \"{}\",
|
short_solution: \"{}\",
|
||||||
long_solution: \"{}\",
|
long_solution: \"{}\",
|
||||||
support_link: \"{}\",
|
|
||||||
}},\
|
}},\
|
||||||
", category_num, error_num, name, message, short_description, long_description, short_solution, long_solution, support_link)
|
", category_num, error_num, name, message, short_description, long_description, short_solution, long_solution)
|
||||||
).expect("unable to write");
|
).expect("unable to write");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@ struct ErrorInfo {
|
||||||
long_description: &'static str,
|
long_description: &'static str,
|
||||||
short_solution: &'static str,
|
short_solution: &'static str,
|
||||||
long_solution: &'static str,
|
long_solution: &'static str,
|
||||||
support_link: &'static str,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ErrorInfo {
|
impl Default for ErrorInfo {
|
||||||
|
|
@ -47,15 +46,12 @@ impl Default for ErrorInfo {
|
||||||
long_solution: "unknown",
|
long_solution: "unknown",
|
||||||
short_description: "unknown",
|
short_description: "unknown",
|
||||||
short_solution: "unknown",
|
short_solution: "unknown",
|
||||||
support_link: "unknown",
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static ERROR_CODE_REGEX: Lazy<Regex> =
|
static ERROR_CODE_REGEX: Lazy<Regex> =
|
||||||
Lazy::new(|| Regex::new("\\b\\d\\d\\d-\\d\\d\\d\\d\\b").expect("invalid regex"));
|
Lazy::new(|| Regex::new("\\b\\d\\d\\d-\\d\\d\\d\\d\\b").expect("invalid regex"));
|
||||||
static WORD_BOUNDARY_START: Lazy<Regex> = Lazy::new(|| Regex::new("^\\b").expect("invalid regex"));
|
|
||||||
static WORD_BOUNDARY_END: Lazy<Regex> = Lazy::new(|| Regex::new("\\b$").expect("invalid regex"));
|
|
||||||
|
|
||||||
pub struct ErrorCodeHandler;
|
pub struct ErrorCodeHandler;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
use serenity::all::{ActivityData, ActivityType, ChannelId, Colour, Command, CommandId, Context, CreateCommand, CreateEmbed, CreateEmbedAuthor, CreateInputText, CreateInteractionResponse, CreateInteractionResponseMessage, CreateMessage, CreateQuickModal, EventHandler, Guild, GuildId, InputTextStyle, Interaction, Message, Ready, Timestamp};
|
use serenity::all::{ChannelId, Colour, Command, CommandId, Context, CreateCommand, CreateEmbed, CreateEmbedAuthor, CreateInteractionResponse, CreateInteractionResponseMessage, CreateMessage, CreateQuickModal, EventHandler, Interaction, Ready, Timestamp};
|
||||||
use serenity::async_trait;
|
use serenity::async_trait;
|
||||||
use tokio::sync::OnceCell;
|
use tokio::sync::OnceCell;
|
||||||
|
|
||||||
|
|
@ -10,7 +10,7 @@ pub struct MiiverseModApplicationHandler{
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl EventHandler for MiiverseModApplicationHandler {
|
impl EventHandler for MiiverseModApplicationHandler {
|
||||||
async fn ready(&self, ctx: Context, data_about_bot: Ready) {
|
async fn ready(&self, ctx: Context, _data_about_bot: Ready) {
|
||||||
let command = CreateCommand::new("mod-application")
|
let command = CreateCommand::new("mod-application")
|
||||||
.description("Apply for moderator");
|
.description("Apply for moderator");
|
||||||
|
|
||||||
|
|
@ -56,7 +56,7 @@ impl EventHandler for MiiverseModApplicationHandler {
|
||||||
|
|
||||||
let emergency_channel = ChannelId::new(1504018819071610970);
|
let emergency_channel = ChannelId::new(1504018819071610970);
|
||||||
|
|
||||||
let mut author = CreateEmbedAuthor::from(response.interaction.user);
|
let author = CreateEmbedAuthor::from(response.interaction.user);
|
||||||
|
|
||||||
let embed = CreateEmbed::new()
|
let embed = CreateEmbed::new()
|
||||||
.title("Moderator Application")
|
.title("Moderator Application")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue