Documemtaiom
This commit is contained in:
parent
b897e44cca
commit
499faefa51
|
@ -13,6 +13,7 @@ use crate::types::{GatewayIdentifyPayload, LoginResult, LoginSchema};
|
||||||
|
|
||||||
impl Instance {
|
impl Instance {
|
||||||
/// Logs into an existing account on the spacebar server.
|
/// Logs into an existing account on the spacebar server.
|
||||||
|
// TODO: Couldn't find reference
|
||||||
pub async fn login_account(&mut self, login_schema: &LoginSchema) -> ChorusResult<UserMeta> {
|
pub async fn login_account(&mut self, login_schema: &LoginSchema) -> ChorusResult<UserMeta> {
|
||||||
let endpoint_url = self.urls.api.clone() + "/auth/login";
|
let endpoint_url = self.urls.api.clone() + "/auth/login";
|
||||||
let chorus_request = ChorusRequest {
|
let chorus_request = ChorusRequest {
|
||||||
|
|
|
@ -15,6 +15,7 @@ use crate::{
|
||||||
|
|
||||||
impl Instance {
|
impl Instance {
|
||||||
/// Registers a new user on the server.
|
/// Registers a new user on the server.
|
||||||
|
// TODO: Couldn't find reference
|
||||||
pub async fn register_account(
|
pub async fn register_account(
|
||||||
&mut self,
|
&mut self,
|
||||||
register_schema: &RegisterSchema,
|
register_schema: &RegisterSchema,
|
||||||
|
|
|
@ -12,6 +12,9 @@ use crate::{
|
||||||
|
|
||||||
impl Channel {
|
impl Channel {
|
||||||
/// Retrieves a channel from the server.
|
/// Retrieves a channel from the server.
|
||||||
|
///
|
||||||
|
/// # Reference
|
||||||
|
/// See <https://discord-userdoccers.vercel.app/resources/channel#get-channel>
|
||||||
pub async fn get(user: &mut UserMeta, channel_id: Snowflake) -> ChorusResult<Channel> {
|
pub async fn get(user: &mut UserMeta, channel_id: Snowflake) -> ChorusResult<Channel> {
|
||||||
let url = user.belongs_to.borrow().urls.api.clone();
|
let url = user.belongs_to.borrow().urls.api.clone();
|
||||||
let chorus_request = ChorusRequest {
|
let chorus_request = ChorusRequest {
|
||||||
|
@ -24,6 +27,9 @@ impl Channel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deletes self.
|
/// Deletes self.
|
||||||
|
///
|
||||||
|
/// # Reference
|
||||||
|
/// See <https://discord-userdoccers.vercel.app/resources/channel#delete-channel>
|
||||||
pub async fn delete(self, user: &mut UserMeta) -> ChorusResult<()> {
|
pub async fn delete(self, user: &mut UserMeta) -> ChorusResult<()> {
|
||||||
let chorus_request = ChorusRequest {
|
let chorus_request = ChorusRequest {
|
||||||
request: Client::new()
|
request: Client::new()
|
||||||
|
@ -40,6 +46,9 @@ impl Channel {
|
||||||
|
|
||||||
/// Modifies a channel with the provided data.
|
/// Modifies a channel with the provided data.
|
||||||
/// Returns the new Channel.
|
/// Returns the new Channel.
|
||||||
|
///
|
||||||
|
/// # Reference
|
||||||
|
/// See <https://discord-userdoccers.vercel.app/resources/channel#modify-channel>
|
||||||
pub async fn modify(
|
pub async fn modify(
|
||||||
&self,
|
&self,
|
||||||
modify_data: ChannelModifySchema,
|
modify_data: ChannelModifySchema,
|
||||||
|
@ -61,6 +70,9 @@ impl Channel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fetches recent messages from a channel.
|
/// Fetches recent messages from a channel.
|
||||||
|
///
|
||||||
|
/// # Reference
|
||||||
|
/// See <https://discord-userdoccers.vercel.app/resources/message#get-messages>
|
||||||
pub async fn messages(
|
pub async fn messages(
|
||||||
range: GetChannelMessagesSchema,
|
range: GetChannelMessagesSchema,
|
||||||
channel_id: Snowflake,
|
channel_id: Snowflake,
|
||||||
|
@ -83,8 +95,10 @@ impl Channel {
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Adds a recipient to a group DM.
|
||||||
|
///
|
||||||
/// # Reference:
|
/// # Reference:
|
||||||
/// Read: <https://discord-userdoccers.vercel.app/resources/channel#add-channel-recipient>
|
/// See <https://discord-userdoccers.vercel.app/resources/channel#add-channel-recipient>
|
||||||
pub async fn add_channel_recipient(
|
pub async fn add_channel_recipient(
|
||||||
&self,
|
&self,
|
||||||
recipient_id: Snowflake,
|
recipient_id: Snowflake,
|
||||||
|
@ -110,8 +124,10 @@ impl Channel {
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Removes a recipient from a group DM.
|
||||||
|
///
|
||||||
/// # Reference:
|
/// # Reference:
|
||||||
/// Read: <https://discord-userdoccers.vercel.app/resources/channel#remove-channel-recipient>
|
/// See <https://discord-userdoccers.vercel.app/resources/channel#remove-channel-recipient>
|
||||||
pub async fn remove_channel_recipient(
|
pub async fn remove_channel_recipient(
|
||||||
&self,
|
&self,
|
||||||
recipient_id: Snowflake,
|
recipient_id: Snowflake,
|
||||||
|
|
|
@ -12,6 +12,9 @@ use crate::types::{Message, MessageSendSchema, Snowflake};
|
||||||
impl Message {
|
impl Message {
|
||||||
/// Sends a message in the channel with the provided channel_id.
|
/// Sends a message in the channel with the provided channel_id.
|
||||||
/// Returns the sent message.
|
/// Returns the sent message.
|
||||||
|
///
|
||||||
|
/// # Reference
|
||||||
|
/// See <https://discord-userdoccers.vercel.app/resources/message#create-message>
|
||||||
pub async fn send(
|
pub async fn send(
|
||||||
user: &mut UserMeta,
|
user: &mut UserMeta,
|
||||||
channel_id: Snowflake,
|
channel_id: Snowflake,
|
||||||
|
@ -71,8 +74,12 @@ impl Message {
|
||||||
impl UserMeta {
|
impl UserMeta {
|
||||||
/// Sends a message in the channel with the provided channel_id.
|
/// Sends a message in the channel with the provided channel_id.
|
||||||
/// Returns the sent message.
|
/// Returns the sent message.
|
||||||
|
///
|
||||||
/// # Notes
|
/// # Notes
|
||||||
/// Shorthand call for Message::send()
|
/// Shorthand call for [`Message::send`]
|
||||||
|
///
|
||||||
|
/// # Reference
|
||||||
|
/// See <https://discord-userdoccers.vercel.app/resources/message#create-message>
|
||||||
pub async fn send_message(
|
pub async fn send_message(
|
||||||
&mut self,
|
&mut self,
|
||||||
message: MessageSendSchema,
|
message: MessageSendSchema,
|
||||||
|
|
|
@ -11,6 +11,9 @@ use crate::{
|
||||||
|
|
||||||
impl types::Channel {
|
impl types::Channel {
|
||||||
/// Edits the permission overwrites for a channel.
|
/// Edits the permission overwrites for a channel.
|
||||||
|
///
|
||||||
|
/// # Reference
|
||||||
|
/// See <https://discord-userdoccers.vercel.app/resources/channel#modify-channel-permissions>
|
||||||
pub async fn edit_permissions(
|
pub async fn edit_permissions(
|
||||||
user: &mut UserMeta,
|
user: &mut UserMeta,
|
||||||
channel_id: Snowflake,
|
channel_id: Snowflake,
|
||||||
|
@ -38,6 +41,9 @@ impl types::Channel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deletes a permission overwrite for a channel.
|
/// Deletes a permission overwrite for a channel.
|
||||||
|
///
|
||||||
|
/// # Reference
|
||||||
|
/// See <https://discord-userdoccers.vercel.app/resources/channel#delete-channel-permission>
|
||||||
pub async fn delete_permission(
|
pub async fn delete_permission(
|
||||||
user: &mut UserMeta,
|
user: &mut UserMeta,
|
||||||
channel_id: Snowflake,
|
channel_id: Snowflake,
|
||||||
|
|
|
@ -16,6 +16,10 @@ impl UserMeta {
|
||||||
///
|
///
|
||||||
/// # Notes
|
/// # Notes
|
||||||
/// This function is a wrapper around [`User::get`].
|
/// This function is a wrapper around [`User::get`].
|
||||||
|
///
|
||||||
|
/// # Reference
|
||||||
|
/// See <https://discord-userdoccers.vercel.app/resources/user#get-user> and
|
||||||
|
/// <https://discord-userdoccers.vercel.app/resources/user#get-current-user>
|
||||||
pub async fn get(user: &mut UserMeta, id: Option<&String>) -> ChorusResult<User> {
|
pub async fn get(user: &mut UserMeta, id: Option<&String>) -> ChorusResult<User> {
|
||||||
User::get(user, id).await
|
User::get(user, id).await
|
||||||
}
|
}
|
||||||
|
@ -33,6 +37,9 @@ impl UserMeta {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Modifies the current user's representation. (See [`User`])
|
/// Modifies the current user's representation. (See [`User`])
|
||||||
|
///
|
||||||
|
/// # Reference
|
||||||
|
/// See <https://discord-userdoccers.vercel.app/resources/user#modify-current-user>
|
||||||
pub async fn modify(&mut self, modify_schema: UserModifySchema) -> ChorusResult<User> {
|
pub async fn modify(&mut self, modify_schema: UserModifySchema) -> ChorusResult<User> {
|
||||||
if modify_schema.new_password.is_some()
|
if modify_schema.new_password.is_some()
|
||||||
|| modify_schema.email.is_some()
|
|| modify_schema.email.is_some()
|
||||||
|
@ -57,6 +64,9 @@ impl UserMeta {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deletes the user from the Instance.
|
/// Deletes the user from the Instance.
|
||||||
|
///
|
||||||
|
/// # Reference
|
||||||
|
/// See <https://discord-userdoccers.vercel.app/resources/user#disable-user>
|
||||||
pub async fn delete(mut self) -> ChorusResult<()> {
|
pub async fn delete(mut self) -> ChorusResult<()> {
|
||||||
let request = Client::new()
|
let request = Client::new()
|
||||||
.post(format!(
|
.post(format!(
|
||||||
|
@ -74,6 +84,10 @@ impl UserMeta {
|
||||||
|
|
||||||
impl User {
|
impl User {
|
||||||
/// Gets a user by id, or if the id is None, gets the current user.
|
/// Gets a user by id, or if the id is None, gets the current user.
|
||||||
|
///
|
||||||
|
/// # Reference
|
||||||
|
/// See <https://discord-userdoccers.vercel.app/resources/user#get-user> and
|
||||||
|
/// <https://discord-userdoccers.vercel.app/resources/user#get-current-user>
|
||||||
pub async fn get(user: &mut UserMeta, id: Option<&String>) -> ChorusResult<User> {
|
pub async fn get(user: &mut UserMeta, id: Option<&String>) -> ChorusResult<User> {
|
||||||
let url_api = user.belongs_to.borrow().urls.api.clone();
|
let url_api = user.belongs_to.borrow().urls.api.clone();
|
||||||
let url = if id.is_none() {
|
let url = if id.is_none() {
|
||||||
|
@ -96,6 +110,7 @@ impl User {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the user's settings.
|
/// Gets the user's settings.
|
||||||
|
// TODO: Couldn't find reference
|
||||||
pub async fn get_settings(
|
pub async fn get_settings(
|
||||||
token: &String,
|
token: &String,
|
||||||
url_api: &String,
|
url_api: &String,
|
||||||
|
@ -127,6 +142,10 @@ impl Instance {
|
||||||
///
|
///
|
||||||
/// # Notes
|
/// # Notes
|
||||||
/// This function is a wrapper around [`User::get`].
|
/// This function is a wrapper around [`User::get`].
|
||||||
|
///
|
||||||
|
/// # Reference
|
||||||
|
/// See <https://discord-userdoccers.vercel.app/resources/user#get-user> and
|
||||||
|
/// <https://discord-userdoccers.vercel.app/resources/user#get-current-user>
|
||||||
pub async fn get_user(&mut self, token: String, id: Option<&String>) -> ChorusResult<User> {
|
pub async fn get_user(&mut self, token: String, id: Option<&String>) -> ChorusResult<User> {
|
||||||
let mut user = UserMeta::shell(Rc::new(RefCell::new(self.clone())), token).await;
|
let mut user = UserMeta::shell(Rc::new(RefCell::new(self.clone())), token).await;
|
||||||
let result = User::get(&mut user, id).await;
|
let result = User::get(&mut user, id).await;
|
||||||
|
|
|
@ -12,6 +12,10 @@ use crate::types::{
|
||||||
|
|
||||||
#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Updateable)]
|
#[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Updateable)]
|
||||||
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
|
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
|
||||||
|
/// Represents a guild of private channel
|
||||||
|
///
|
||||||
|
/// # Reference
|
||||||
|
/// See <https://discord-userdoccers.vercel.app/resources/channel#channels-resource>
|
||||||
pub struct Channel {
|
pub struct Channel {
|
||||||
pub application_id: Option<Snowflake>,
|
pub application_id: Option<Snowflake>,
|
||||||
#[cfg(feature = "sqlx")]
|
#[cfg(feature = "sqlx")]
|
||||||
|
@ -120,27 +124,55 @@ pub struct DefaultReaction {
|
||||||
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
|
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
|
||||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||||
#[repr(i32)]
|
#[repr(i32)]
|
||||||
|
/// # Reference
|
||||||
|
/// See <https://discord-userdoccers.vercel.app/resources/channel#channel-type>
|
||||||
pub enum ChannelType {
|
pub enum ChannelType {
|
||||||
#[default]
|
#[default]
|
||||||
|
/// A text channel within a guild
|
||||||
GuildText = 0,
|
GuildText = 0,
|
||||||
|
/// A private channel between two users
|
||||||
Dm = 1,
|
Dm = 1,
|
||||||
|
/// A voice channel within a guild
|
||||||
GuildVoice = 2,
|
GuildVoice = 2,
|
||||||
|
/// A private channel between multiple users
|
||||||
GroupDm = 3,
|
GroupDm = 3,
|
||||||
|
/// An organizational category that contains up to 50 channels
|
||||||
GuildCategory = 4,
|
GuildCategory = 4,
|
||||||
|
/// Similar to [GuildText], a channel that users can follow and crosspost into their own guild
|
||||||
GuildNews = 5,
|
GuildNews = 5,
|
||||||
|
/// A channel in which game developers can sell their game on Discord
|
||||||
|
///
|
||||||
|
/// # Note
|
||||||
|
/// Deprecated.
|
||||||
GuildStore = 6,
|
GuildStore = 6,
|
||||||
|
// FIXME userdoccers says 7 is GuildLfg, is this a spacebar specific thing?
|
||||||
Encrypted = 7,
|
Encrypted = 7,
|
||||||
|
// FIXME userdoccers says 8 is LfgGuildDm, is this a spacebar specific thing?
|
||||||
EncryptedThreads = 8,
|
EncryptedThreads = 8,
|
||||||
|
// FIXME userdoccers says 9 is ThreadAlpha, was this changed?
|
||||||
Transactional = 9,
|
Transactional = 9,
|
||||||
|
/// A thread within a [GuildNews] channel
|
||||||
GuildNewsThread = 10,
|
GuildNewsThread = 10,
|
||||||
|
/// A thread within a [GuildText], [GuildForum], or [GuildMedia] channel
|
||||||
GuildPublicThread = 11,
|
GuildPublicThread = 11,
|
||||||
|
/// A thread within a [GuildText] channel, that is only viewable by those invited and those with the [ManageThreads] permission
|
||||||
GuildPrivateThread = 12,
|
GuildPrivateThread = 12,
|
||||||
|
/// A voice channel for hosting events with an audience in a guild
|
||||||
GuildStageVoice = 13,
|
GuildStageVoice = 13,
|
||||||
|
/// The main channel in a hub containing the listed guilds
|
||||||
Directory = 14,
|
Directory = 14,
|
||||||
|
/// A channel that can only contain threads
|
||||||
GuildForum = 15,
|
GuildForum = 15,
|
||||||
|
/// A channel that can only contain threads in a gallery view
|
||||||
|
GuildMedia = 16,
|
||||||
|
// TODO: Couldn't find reference
|
||||||
TicketTracker = 33,
|
TicketTracker = 33,
|
||||||
|
// TODO: Couldn't find reference
|
||||||
Kanban = 34,
|
Kanban = 34,
|
||||||
|
// TODO: Couldn't find reference
|
||||||
VoicelessWhiteboard = 35,
|
VoicelessWhiteboard = 35,
|
||||||
|
// TODO: Couldn't find reference
|
||||||
CustomStart = 64,
|
CustomStart = 64,
|
||||||
|
// TODO: Couldn't find reference
|
||||||
Unhandled = 255,
|
Unhandled = 255,
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,8 @@ use sqlx::Type;
|
||||||
const EPOCH: i64 = 1420070400000;
|
const EPOCH: i64 = 1420070400000;
|
||||||
|
|
||||||
/// Unique identifier including a timestamp.
|
/// Unique identifier including a timestamp.
|
||||||
|
///
|
||||||
|
/// # Reference
|
||||||
/// See <https://discord.com/developers/docs/reference#snowflakes>
|
/// See <https://discord.com/developers/docs/reference#snowflakes>
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||||
#[cfg_attr(feature = "sqlx", derive(Type))]
|
#[cfg_attr(feature = "sqlx", derive(Type))]
|
||||||
|
|
Loading…
Reference in New Issue