A mdBook preprocessor for building Discord Webcomponents
This project is build on top of skyra-project/discord-components
Work in progress
Test site: https://nilpointer-software.github.io/mdbook-discord-components/
\``` discord yaml
- username: Spen
user_id: 696368083517964288 # This filed will only work on a proper mdbook-discord-components deployment
color: "#b9a0e0"
highight: true
content: |
!echo
- username: Wiki Bot
avatar: https://avatars.githubusercontent.com/u/63750675
color: "#b9a0e0"
bot: true
verified: true
ephemeral: true
edited: true
timestamp: Today at 00:00
reactions:
- emoji: https://em-content.zobj.net/thumbs/120/mozilla/36/heavy-black-heart_2764.png
name: ":heart:"
count: 5
interactive: true
reacted: true
roles: # Role map to properly color role mentions (RoleName: role_color)
Blue: blue
Red: red
content: |
Hello <@Spen> <@Blue> <#Channel>! Sent <t:8531 years ago>
embed:
title: Test Embed
url: https://github.com/NilPointer-Software/mdbook-discord-components
color: red
timestamp: 07/07/2023
description: Hello embed!!
author:
text: Author
image: https://avatars.githubusercontent.com/u/63750675
url: https://github.com/NilPointer-Software/mdbook-discord-components
fields:
- name: Test
value: Hello
inline: true
inline_index: 1
- name: Test 2
value: aaa
inline: true
inline_index: 2
footer:
text: Hiii
attachments:
- url: https://avatars.githubusercontent.com/u/63750675?s=100
- url: https://avatars.githubusercontent.com/u/63750675?s=200
width: 200
height: 200
alt: bigger
components: # Component syntax is a bit funky for now
- # This is an action row
- type: success
label: First row
-
- type: success
label: Second row
embeds:
- title: Test Embed 2
timestamp: 07/07/2023
description: Hello embed!!
image: https://avatars.githubusercontent.com/u/63750675?s=100
fields:
- name: Test
value: Hello
inline: true
inline_index: 1
- name: Test 2
value: aaa
inline: true
inline_index: 2
footer:
text: Hiii
- title: Test Embed 3
timestamp: 07/07/2023
description: Hello embed!!
thumbnail: https://avatars.githubusercontent.com/u/63750675
fields:
- name: Test
value: Hello
inline: true
inline_index: 1
- name: Test 2
value: aaa
inline: true
inline_index: 2
footer:
text: Hiii
- type: join
content: | # You can put html tags inside yaml strings
Welcome, <i style="color: a155ab;">Snazzah</i>. We hope you brought pizza.
- username: Snazzah
reply:
author: Spen
mentions: true
content: "!echo"
content: No. <e:https://avatars.githubusercontent.com/u/63750675>
- username: Wiki Bot
avatar: https://avatars.githubusercontent.com/u/63750675
command:
author: Big_O
command: /test
content: |
Hello <!@Big_O>
\```
Please look at the yaml_parser.rs file for available fields.
Field | Type | Description |
---|---|---|
type | SystemMessageType | The type of the system message |
channel_name? | Boolean | Whether this message is to show channel name changes, used to match Discord's style |
timestamp? | String | Text that will show where the message timestamp is |
content | String | The text of the system message |
SystemMessageType is a String with the following valid values:
Value | Description |
---|---|
alert | System alert message |
boost | Server boost message |
call | Call message |
edit | Channel edit message |
error | System error message |
join | Server join message |
leave | Server leave message |
missed_call | Missed call message |
pin | Pin message |
thread | Thread message |
Field | Type | Description |
---|---|---|
user_id? | Snowflake | Author user ID. Works only with a proper deployment |
username | String | The author username. Will overwrite data from user_id |
avatar? | String | The author avatar url. Will overwrite data from user_id |
color? | String | CSS valid color of the author username (analog to role color) |
timestamp? | String | Text that will show where the message timestamp is |
bot? | Boolean | Whatever the user is a bot. Will overwrite data from user_id |
verified? | Boolean | Whatever the bot is verified |
edited? | Boolean | If the message was edited |
ephemeral? | Boolean | If the message is ephemeral |
roles? | String -> Color map | Role color map used to properly color role mentions |
embed? | Embed | A single embed element. If embeds is present, this will be the first embed show |
embeds? | Array of Embed | Array of embed elements |
reactions? | Array of Reaction | Array of reactions |
attachments? | Array of Attachment | Array of image attachments |
components? | Array of ActionRow | Array of action rows |
invites? | Array of Invite | Array of invitations |
reply? | Reply | Reply information |
command? | Command | Slash command information |
content? | String | The message content |
Field | Type | Description |
---|---|---|
title? | String | Embed title text |
url? | String | Embed title url |
color? | String | CSS valid color of the embed |
description? | String | Embed description text |
image? | String | Image url |
thumbnail? | String | Thumbnail url |
author? | Author | Embed author data |
fields? | Array of Field | Embed fields |
footer? | Footer | Embed footer |
Field | Type | Description |
---|---|---|
text | String | Embed author text |
image? | String | Author image url |
url? | String | Embed author url |
Field | Type | Description |
---|---|---|
name | String | Field name |
value | String | Field value |
inline? | Boolean | If the field should be inline. Requires inline_index |
inline_index? | Integer | The index of the field (position) |
Field | Type | Description |
---|---|---|
text? | String | Footer text |
image? | String | Footer image url |
timestamp? | String | Footer timestamp. Must be in the following format 01/31/2000 |
Field | Type | Description |
---|---|---|
emoji | String | Emoji image url |
name? | String | The name of the reaction. Used as alternative text |
count? | Integer | Reaction count. Must be positive |
interactive? | Boolean | If the reaction should be interactive |
reacted? | Boolean | Should the reaction show up as reacted |
Field | Type | Description |
---|---|---|
url | String | The image attachment url |
width? | Integer | The width of the image |
height? | Integer | The hight of the image |
alt? | String | The alternative text of the image |
ActionRow is an Array of Button
Example:
- username: Example
content: This is an example of components
components: # Component syntax is a bit funky for now
- # This is an action row
- type: success
label: First row
-
- type: success
label: Second row
Field | Type | Description |
---|---|---|
type | ButtonType | The type of the button |
label | String | Button text |
disabled? | Boolean | Whatever the button should be disabled |
emoji? | String | Emoji image url |
emmoji_name? | String | The name of the emoji |
url? | String | The url of the button if used with the secondary type |
ButtonType is a String with the following valid values:
Value | Description |
---|---|
primary | A blue button style |
secondary | A grey button style |
success | A green button style |
destructive | A red button style |
Field | Type | Description |
---|---|---|
name | String | Invite server name |
members | Integer | Server member count. Must be positive |
online | Integer | Currently online member count. Must be positive |
icon? | String | Server icon url |
partnered? | Boolean | Is the server partnered |
verified? | Boolean | Is the server verified |
Field | Type | Description |
---|---|---|
content | String | Referenced message content |
author? | String | Referenced message author username |
user_id? | Snowflake | Referrenced message author ID. Will override author, avatar, and bot |
avatar? | String | Referenced message author avatar url |
bot? | Boolean | Whether the referenced message author is a bot |
verified? | Boolean | Whether the referenced message author is a verified bot |
mentions? | Boolean | Whether the reply should mention the referenced message author |
op? | Boolean | Whether the referenced message author was the original poster in a thread |
color? | String | Referenced message author role color |
attachment? | Boolean | Whether the referenced message contains attachments |
edited? | Boolean | Whether the referenced message was edited |
command? | Bollean | Whether the referenced message was a response to a slash command |
Field | Type | Description |
---|---|---|
command | String | The invoked slash command name |
author? | String | The user who executed the slash command |
user_id? | Snowflake | Executing user ID. Will override author, and avatar |
avatar? | String | Executing user avatar url |
color? | String | Executing user role color |