-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3
- Loading branch information
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import discord_gleam/types/message.{type Embed} | ||
import gleam/json | ||
import gleam/list | ||
|
||
pub type Reply { | ||
Reply(content: String, message_id: String, embeds: List(Embed)) | ||
} | ||
|
||
pub fn to_string(msg: Reply) -> String { | ||
let embeds_json = list.map(msg.embeds, embed_to_json) | ||
json.object([ | ||
#("content", json.string(msg.content)), | ||
#("embeds", json.array(embeds_json, of: fn(x) { x })), | ||
#( | ||
"message_reference", | ||
json.object([#("message_id", json.string(msg.message_id))]), | ||
), | ||
]) | ||
|> json.to_string | ||
} | ||
|
||
pub fn embed_to_json(embed: Embed) -> json.Json { | ||
json.object([ | ||
#("title", json.string(embed.title)), | ||
#("description", json.string(embed.description)), | ||
#("color", json.int(embed.color)), | ||
]) | ||
} |