Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
feat: embeds
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Jul 7, 2022
1 parent 57693d3 commit 4293dd5
Show file tree
Hide file tree
Showing 3 changed files with 250 additions and 54 deletions.
118 changes: 110 additions & 8 deletions configuration.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
"$ref": "#/$defs/channels",
"description": "A list of channel ids. The bot will only introduce in threads under these channels."
},
"message": {
"$ref": "#/$defs/message",
"description": "The message to send when the thread has been created."
"response": {
"$ref": "#/$defs/response",
"description": "The response to send when the thread has been created."
}
}
},
Expand Down Expand Up @@ -91,9 +91,9 @@
},
"description": "The conditions to respond to the message."
},
"message": {
"$ref": "#/$defs/message",
"description": "The message to send when the message is responded to."
"response": {
"$ref": "#/$defs/response",
"description": "The response to send when the message is responded to."
}
},
"description": "The conditions to respond to a message."
Expand Down Expand Up @@ -128,8 +128,110 @@
"uniqueItems": true,
"minItems": 1
},
"message": {
"type": "string"
"embed": {
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "The title of the embed."
},
"description": {
"type": "string",
"description": "The description of the embed."
},
"color": {
"type": "integer",
"description": "The color of the embed."
},
"fields": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the field."
},
"value": {
"type": "string",
"description": "The value of the field."
},
"inline": {
"type": "boolean",
"description": "Whether the field is inline."
}
},
"description": "The field to add to the embed."
},
"description": "The fields to add to the embed."
},
"image": {
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "The url of the image."
}
},
"description": "The image to add to the embed."
},
"thumbnail": {
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "The url of the thumbnail."
}
},
"description": "The thumbnail to add to the embed."
},
"author": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the author."
},
"url": {
"type": "string",
"description": "The url of the author."
},
"icon_url": {
"type": "string",
"description": "The url of the author's icon."
}
},
"description": "The author to add to the embed."
},
"footer": {
"type": "object",
"properties": {
"text": {
"type": "string",
"description": "The text of the footer."
},
"icon_url": {
"type": "string",
"description": "The url of the footer's icon."
}
},
"description": "The footer to add to the embed."
}
}
},
"response": {
"type": "object",
"properties": {
"message": {
"type": "string",
"description": "The message. Can be empty if the embed is not empty"
},
"embed": {
"$ref": "#/$defs/embed",
"description": "The embed to send."
}
},
}
}
}
}
61 changes: 59 additions & 2 deletions src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct Administrators {
#[serde(rename_all = "camelCase")]
pub struct Introduction {
pub channels: Vec<u64>,
pub message: String,
pub response: Response,
}

#[derive(Serialize, Deserialize)]
Expand All @@ -35,7 +35,64 @@ pub struct MessageResponder {
pub includes: Includes,
pub excludes: Excludes,
pub condition: Condition,
pub message: String,
pub response: Response,
}

#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Response {
pub message: Option<String>,
pub embed: Option<Embed>,
}

#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Embed {
pub title: String,
pub description: String,
pub color: i32,
pub fields: Vec<Field>,
pub footer: Footer,
pub image: Image,
pub thumbnail: Thumbnail,
pub author: Author,
}

#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Field {
pub name: String,
pub value: String,
pub inline: bool,
}

#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Footer {
pub text: String,
#[serde(rename = "icon_url")]
pub icon_url: String,
}

#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Image {
pub url: String,
}

#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Thumbnail {
pub url: String,
}

#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Author {
pub name: String,
#[serde(rename = "icon_url")]
pub icon_url: String,
pub url: String,
}

#[derive(Serialize, Deserialize)]
Expand Down
Loading

0 comments on commit 4293dd5

Please sign in to comment.