-
-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Zeyla Hellyer <zeyla@hellyer.dev>
- Loading branch information
1 parent
f7beb72
commit 1d3f210
Showing
134 changed files
with
2,562 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[package] | ||
authors = ["Zeyla Hellyer <zeyla@hellyer.dev>"] | ||
documentation = "https://docs.rs/lmao-model" | ||
edition = "2018" | ||
homepage = "https://github.com/lmao-rs/lmao" | ||
include = ["src/*.rs", "Cargo.toml"] | ||
keywords = ["discord", "discord-api", "lmao"] | ||
license = "ISC" | ||
name = "lmao-model" | ||
publish = false | ||
readme = "README.md" | ||
repository = "https://github.com/lmao-rs/lmao.git" | ||
version = "0.1.0" | ||
|
||
[dependencies] | ||
bitflags = "1" | ||
chrono = { features = ["serde"], optional = true, version = "0.4" } | ||
serde = { features = ["derive"], version = "1" } | ||
serde_json = "1" | ||
serde_repr = "0.1" | ||
|
||
[features] | ||
default = ["chrono", "chrono/serde"] |
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 @@ | ||
../LICENSE.md |
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,43 @@ | ||
[![license badge][]][license link] [![rust badge]][rust link] | ||
|
||
# lmao-model | ||
|
||
See the [`lmao`] documentation for more information. | ||
|
||
`lmao-model` is a crate of only serde models defining the Discord APIs with | ||
no implementations on top of them or functions to work with them. | ||
|
||
These are in a single crate for ease of use, a single point of definition, | ||
and a sort of versioning of the Discord API. Similar to how a database | ||
schema progresses in versions, the definition of the API also progresses in | ||
versions. | ||
|
||
The types in this crate are reproducible: deserializing a payload into a | ||
type, serializing it, and then deserializing it again will work. | ||
|
||
Defined are a number of modules defining types returned by or owned by | ||
resource categories. For example, `gateway` are types used to interact with | ||
and returned by the gateway API. `guild` contains types owned by the Guild | ||
resource category. These types may be directly returned by, built on top of, | ||
or extended by other crates. | ||
|
||
### Installation | ||
|
||
This crate requires Rust 1.31+. | ||
|
||
Add the following to your `Cargo.toml`: | ||
|
||
```toml | ||
lmao-model = "0.1" | ||
``` | ||
|
||
## License | ||
|
||
[ISC][LICENSE.md] | ||
|
||
[LICENSE.md]: https://github.com/zeyla/lmao/blob/master/LICENSE.md | ||
[`lmao`]: https://docs.rs/lmao | ||
[license badge]: https://img.shields.io/badge/license-ISC-blue.svg?style=flat-square | ||
[license link]: https://opensource.org/licenses/ISC | ||
[rust badge]: https://img.shields.io/badge/rust-1.31+-93450a.svg?style=flat-square | ||
[rust link]: https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html |
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,13 @@ | ||
use crate::id::AttachmentId; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct Attachment { | ||
pub id: AttachmentId, | ||
pub filename: String, | ||
pub height: Option<u64>, | ||
pub proxy_url: String, | ||
pub size: u64, | ||
pub url: String, | ||
pub width: Option<u64>, | ||
} |
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,21 @@ | ||
use crate::{ | ||
channel::{ | ||
permission_overwrite::PermissionOverwrite, | ||
ChannelType, | ||
}, | ||
id::ChannelId, | ||
}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct CategoryChannel { | ||
pub id: ChannelId, | ||
#[serde(rename = "type")] | ||
pub kind: ChannelType, | ||
pub name: String, | ||
#[serde(default)] | ||
pub nsfw: bool, | ||
pub parent_id: Option<ChannelId>, | ||
pub permission_overwrites: Vec<PermissionOverwrite>, | ||
pub position: i64, | ||
} |
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,14 @@ | ||
use crate::{ | ||
channel::ChannelType, | ||
id::{ChannelId, GuildId}, | ||
}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct ChannelMention { | ||
pub guild_id: GuildId, | ||
pub id: ChannelId, | ||
#[serde(rename = "type")] | ||
pub kind: ChannelType, | ||
pub name: String, | ||
} |
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,13 @@ | ||
use serde_repr::{Deserialize_repr, Serialize_repr}; | ||
|
||
#[derive(Clone, Copy, Debug, Deserialize_repr, Eq, Hash, PartialEq, PartialOrd, Ord, Serialize_repr)] | ||
#[repr(u8)] | ||
pub enum ChannelType { | ||
GuildText = 0, | ||
Private = 1, | ||
GuildVoice = 2, | ||
Group = 3, | ||
GuildCategory = 4, | ||
GuildNews = 5, | ||
GuildStore = 6, | ||
} |
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,9 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct EmbedAuthor { | ||
pub icon_url: Option<String>, | ||
pub name: String, | ||
pub proxy_icon_url: Option<String>, | ||
pub url: Option<String>, | ||
} |
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,9 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct EmbedField { | ||
#[serde(default)] | ||
pub inline: bool, | ||
pub name: String, | ||
pub value: String, | ||
} |
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,8 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct EmbedFooter { | ||
pub icon_url: Option<String>, | ||
pub proxy_icon_url: Option<String>, | ||
pub text: String, | ||
} |
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,9 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct EmbedImage { | ||
pub height: u64, | ||
pub proxy_url: String, | ||
pub url: String, | ||
pub width: u64, | ||
} |
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,38 @@ | ||
mod author; | ||
mod field; | ||
mod footer; | ||
mod image; | ||
mod provider; | ||
mod thumbnail; | ||
mod video; | ||
|
||
pub use self::{ | ||
author::EmbedAuthor, | ||
field::EmbedField, | ||
footer::EmbedFooter, | ||
image::EmbedImage, | ||
provider::EmbedProvider, | ||
thumbnail::EmbedThumbnail, | ||
video::EmbedVideo, | ||
}; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct Embed { | ||
pub author: Option<EmbedAuthor>, | ||
pub color: u32, | ||
pub description: Option<String>, | ||
#[serde(default)] | ||
pub fields: Vec<EmbedField>, | ||
pub footer: Option<EmbedFooter>, | ||
pub image: Option<EmbedImage>, | ||
#[serde(rename = "type")] | ||
pub kind: String, | ||
pub provider: Option<EmbedProvider>, | ||
pub thumbnail: Option<EmbedThumbnail>, | ||
pub timestamp: Option<String>, | ||
pub title: Option<String>, | ||
pub url: Option<String>, | ||
pub video: Option<EmbedVideo>, | ||
} |
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,7 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct EmbedProvider { | ||
pub name: String, | ||
pub url: Option<String>, | ||
} |
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,9 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct EmbedThumbnail { | ||
pub height: u64, | ||
pub proxy_url: String, | ||
pub url: String, | ||
pub width: u64, | ||
} |
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,8 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct EmbedVideo { | ||
pub height: u64, | ||
pub url: String, | ||
pub width: u64, | ||
} |
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,23 @@ | ||
use crate::{ | ||
channel::ChannelType, | ||
id::{ApplicationId, ChannelId, MessageId, UserId}, | ||
user::User, | ||
}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct Group { | ||
pub id: ChannelId, | ||
pub application_id: Option<ApplicationId>, | ||
pub icon: Option<String>, | ||
#[serde(rename = "type")] | ||
pub kind: ChannelType, | ||
pub last_message_id: Option<MessageId>, | ||
#[cfg(feature = "chrono")] | ||
pub last_pin_timestamp: Option<chrono::DateTime<chrono::FixedOffset>>, | ||
#[cfg(not(feature = "chrono"))] | ||
pub last_pin_timestamp: Option<String>, | ||
pub name: Option<String>, | ||
pub owner_id: UserId, | ||
pub recipients: Vec<User>, | ||
} |
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,8 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use super::MessageActivityType; | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct MessageActivity { | ||
pub kind: MessageActivityType, | ||
pub party_id: Option<String>, | ||
} |
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,10 @@ | ||
use serde_repr::{Deserialize_repr, Serialize_repr}; | ||
|
||
#[derive(Clone, Copy, Debug, Deserialize_repr, Eq, Hash, PartialEq, PartialOrd, Ord, Serialize_repr)] | ||
#[repr(u8)] | ||
pub enum MessageActivityType { | ||
Join = 1, | ||
Spectate = 2, | ||
Listen = 3, | ||
JoinRequest = 5, | ||
} |
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,11 @@ | ||
use crate::id::ApplicationId; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct MessageApplication { | ||
pub id: ApplicationId, | ||
pub cover_image: Option<String>, | ||
pub description: String, | ||
pub icon: Option<String>, | ||
pub name: String, | ||
} |
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,11 @@ | ||
use bitflags::bitflags; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
bitflags! { | ||
#[derive(Deserialize, Serialize)] | ||
pub struct MessageFlags: u64 { | ||
const CROSSPOSTED = 1; | ||
const IS_CROSSPOST = 1 << 1; | ||
const SUPPRESS_EMBEDS = 1 << 2; | ||
} | ||
} |
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,19 @@ | ||
use serde_repr::{Deserialize_repr, Serialize_repr}; | ||
|
||
#[derive(Clone, Copy, Debug, Deserialize_repr, Eq, Hash, PartialEq, PartialOrd, Ord, Serialize_repr)] | ||
#[repr(u8)] | ||
pub enum MessageType { | ||
Regular = 0, | ||
RecipientAdd = 1, | ||
RecipientRemove = 2, | ||
Call = 3, | ||
ChannelNameChange = 4, | ||
ChannelIconChange = 5, | ||
ChannelMessagePinned = 6, | ||
GuildMemberJoin = 7, | ||
UserPremiumSub = 8, | ||
UserPremiumSubTier1 = 9, | ||
UserPremiumSubTier2 = 10, | ||
UserPremiumSubTier3 = 11, | ||
ChannelFollowAdd = 12, | ||
} |
Oops, something went wrong.