Compare commits

..

No commits in common. "3a5bbb73e0a3db6040ab4b20c95e79744e16bae8" and "4bf7037cf0d610d8219d98f9b6e996c186e83f6c" have entirely different histories.

42 changed files with 284 additions and 135 deletions

4
Cargo.lock generated
View File

@ -252,9 +252,9 @@ dependencies = [
[[package]]
name = "chorus-macros"
version = "0.3.0"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de4221700bc486c6e6bc261fdea478936d33067a06325895f5d2a8cde5917272"
checksum = "a81545a60b926f815517dadbbd40cd502294ae2baea25fa8194d854d607512b0"
dependencies = [
"async-trait",
"quote",

View File

@ -43,7 +43,7 @@ thiserror = "1.0.56"
jsonwebtoken = "8.3.0"
log = "0.4.20"
async-trait = "0.1.77"
chorus-macros = "0.3.0"
chorus-macros = "0.2.0"
sqlx = { version = "0.7.3", features = [
"mysql",
"sqlite",

View File

@ -6,7 +6,6 @@
use custom_error::custom_error;
use crate::types::WebSocketEvent;
use chorus_macros::WebSocketEvent;
custom_error! {
#[derive(PartialEq, Eq, Clone, Hash)]
@ -73,7 +72,7 @@ custom_error! {
/// Supposed to be sent as numbers, though they are sent as string most of the time?
///
/// Also includes errors when initiating a connection and unexpected opcodes
#[derive(PartialEq, Eq, Default, Clone, WebSocketEvent)]
#[derive(PartialEq, Eq, Default, Clone)]
pub GatewayError
// Errors we have received from the gateway
#[default]
@ -100,13 +99,15 @@ custom_error! {
UnexpectedOpcodeReceived{opcode: u8} = "Received an opcode we weren't expecting to receive: {opcode}",
}
impl WebSocketEvent for GatewayError {}
custom_error! {
/// Voice Gateway errors
///
/// Similar to [GatewayError].
///
/// See <https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-close-event-codes>;
#[derive(Clone, Default, PartialEq, Eq, WebSocketEvent)]
#[derive(Clone, Default, PartialEq, Eq)]
pub VoiceGatewayError
// Errors we receive
#[default]
@ -131,9 +132,11 @@ custom_error! {
UnexpectedOpcodeReceived{opcode: u8} = "Received an opcode we weren't expecting to receive: {opcode}",
}
impl WebSocketEvent for VoiceGatewayError {}
custom_error! {
/// Voice UDP errors.
#[derive(Clone, PartialEq, Eq, WebSocketEvent)]
#[derive(Clone, PartialEq, Eq)]
pub VoiceUdpError
// General errors
@ -152,3 +155,4 @@ custom_error! {
CannotConnect{error: String} = "Cannot connect due to a UDP error: {error}",
}
impl WebSocketEvent for VoiceUdpError {}

View File

@ -5,11 +5,12 @@
use serde::{Deserialize, Serialize};
use crate::types::{GuildApplicationCommandPermissions, WebSocketEvent};
use chorus_macros::WebSocketEvent;
#[derive(Debug, Deserialize, Serialize, Default, Clone, WebSocketEvent)]
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#application-command-permissions-update>
pub struct ApplicationCommandPermissionsUpdate {
#[serde(flatten)]
pub permissions: GuildApplicationCommandPermissions,
}
impl WebSocketEvent for ApplicationCommandPermissionsUpdate {}

View File

@ -2,27 +2,28 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use crate::types::{JsonField, SourceUrlField, WebSocketEvent};
use chorus_macros::{JsonField, SourceUrlField, WebSocketEvent};
use crate::types::{JsonField, SourceUrlField};
use chorus_macros::{JsonField, SourceUrlField};
use serde::{Deserialize, Serialize};
use crate::types::{
AutoModerationAction, AutoModerationRule, AutoModerationRuleTriggerType, Snowflake,
WebSocketEvent,
};
#[cfg(feature = "client")]
use super::UpdateMessage;
#[derive(Debug, Deserialize, Serialize, Default, Clone, WebSocketEvent)]
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#auto-moderation-rule-create>
pub struct AutoModerationRuleCreate {
#[serde(flatten)]
pub rule: AutoModerationRule,
}
#[derive(
Debug, Deserialize, Serialize, Default, Clone, JsonField, SourceUrlField, WebSocketEvent,
)]
impl WebSocketEvent for AutoModerationRuleCreate {}
#[derive(Debug, Deserialize, Serialize, Default, Clone, JsonField, SourceUrlField)]
/// See <https://discord.com/developers/docs/topics/gateway-events#auto-moderation-rule-update>
pub struct AutoModerationRuleUpdate {
#[serde(flatten)]
@ -42,14 +43,18 @@ impl UpdateMessage<AutoModerationRule> for AutoModerationRuleUpdate {
}
}
#[derive(Debug, Deserialize, Serialize, Default, Clone, WebSocketEvent)]
impl WebSocketEvent for AutoModerationRuleUpdate {}
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#auto-moderation-rule-delete>
pub struct AutoModerationRuleDelete {
#[serde(flatten)]
pub rule: AutoModerationRule,
}
#[derive(Debug, Deserialize, Serialize, Default, Clone, WebSocketEvent)]
impl WebSocketEvent for AutoModerationRuleDelete {}
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#auto-moderation-action-execution>
pub struct AutoModerationActionExecution {
pub guild_id: Snowflake,
@ -64,3 +69,5 @@ pub struct AutoModerationActionExecution {
pub matched_keyword: Option<String>,
pub matched_content: Option<String>,
}
impl WebSocketEvent for AutoModerationActionExecution {}

View File

@ -5,9 +5,8 @@
use serde::{Deserialize, Serialize};
use crate::types::{Snowflake, VoiceState, WebSocketEvent};
use chorus_macros::WebSocketEvent;
#[derive(Debug, Deserialize, Serialize, Default, Clone, WebSocketEvent)]
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
/// Officially Undocumented;
/// Is sent to a client by the server to signify a new call being created;
///
@ -24,7 +23,9 @@ pub struct CallCreate {
pub channel_id: Snowflake,
}
#[derive(Debug, Deserialize, Serialize, Default, Clone, PartialEq, Eq, WebSocketEvent)]
impl WebSocketEvent for CallCreate {}
#[derive(Debug, Deserialize, Serialize, Default, Clone, PartialEq, Eq)]
/// Officially Undocumented;
/// Updates the client on which calls are ringing, along with a specific call?;
///
@ -39,7 +40,9 @@ pub struct CallUpdate {
pub channel_id: Snowflake,
}
#[derive(Debug, Deserialize, Serialize, Default, Clone, PartialEq, Eq, WebSocketEvent)]
impl WebSocketEvent for CallUpdate {}
#[derive(Debug, Deserialize, Serialize, Default, Clone, PartialEq, Eq)]
/// Officially Undocumented;
/// Deletes a ringing call;
/// Ex: {"t":"CALL_DELETE","s":8,"op":0,"d":{"channel_id":"837609115475771392"}}
@ -47,7 +50,9 @@ pub struct CallDelete {
pub channel_id: Snowflake,
}
#[derive(Debug, Deserialize, Serialize, Default, Clone, PartialEq, Eq, WebSocketEvent)]
impl WebSocketEvent for CallDelete {}
#[derive(Debug, Deserialize, Serialize, Default, Clone, PartialEq, Eq)]
/// Officially Undocumented;
/// See <https://unofficial-discord-docs.vercel.app/gateway/op13>;
///
@ -56,3 +61,4 @@ pub struct CallSync {
pub channel_id: Snowflake,
}
impl WebSocketEvent for CallSync {}

View File

@ -18,7 +18,7 @@ use crate::gateway::Shared;
#[cfg(feature = "client")]
use crate::types::Guild;
#[derive(Debug, Default, Deserialize, Serialize, WebSocketEvent)]
#[derive(Debug, Default, Deserialize, Serialize)]
/// See <https://discord.com/developers/docs/topics/gateway-events#channel-pins-update>
pub struct ChannelPinsUpdate {
pub guild_id: Option<Snowflake>,
@ -26,7 +26,9 @@ pub struct ChannelPinsUpdate {
pub last_pin_timestamp: Option<DateTime<Utc>>,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, JsonField, SourceUrlField, WebSocketEvent)]
impl WebSocketEvent for ChannelPinsUpdate {}
#[derive(Debug, Default, Deserialize, Serialize, Clone, JsonField, SourceUrlField)]
/// See <https://discord.com/developers/docs/topics/gateway-events#channel-create>
pub struct ChannelCreate {
#[serde(flatten)]
@ -37,6 +39,8 @@ pub struct ChannelCreate {
pub source_url: String,
}
impl WebSocketEvent for ChannelCreate {}
#[cfg(feature = "client")]
impl UpdateMessage<Guild> for ChannelCreate {
#[cfg(not(tarpaulin_include))]
@ -55,7 +59,7 @@ impl UpdateMessage<Guild> for ChannelCreate {
}
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, JsonField, SourceUrlField, WebSocketEvent)]
#[derive(Debug, Default, Deserialize, Serialize, Clone, JsonField, SourceUrlField)]
/// See <https://discord.com/developers/docs/topics/gateway-events#channel-update>
pub struct ChannelUpdate {
#[serde(flatten)]
@ -66,6 +70,8 @@ pub struct ChannelUpdate {
pub source_url: String,
}
impl WebSocketEvent for ChannelUpdate {}
#[cfg(feature = "client")]
impl UpdateMessage<Channel> for ChannelUpdate {
fn update(&mut self, object_to_update: Shared<Channel>) {
@ -79,7 +85,7 @@ impl UpdateMessage<Channel> for ChannelUpdate {
}
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// Officially undocumented.
/// Sends updates to client about a new message with its id
/// {"channel_unread_updates": [{"id": "816412869766938648", "last_message_id": "1085892012085104680"}}
@ -97,7 +103,9 @@ pub struct ChannelUnreadUpdateObject {
pub last_pin_timestamp: Option<String>,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, JsonField, SourceUrlField, WebSocketEvent)]
impl WebSocketEvent for ChannelUnreadUpdate {}
#[derive(Debug, Default, Deserialize, Serialize, Clone, JsonField, SourceUrlField)]
/// See <https://discord.com/developers/docs/topics/gateway-events#channel-delete>
pub struct ChannelDelete {
#[serde(flatten)]
@ -132,3 +140,4 @@ impl UpdateMessage<Guild> for ChannelDelete {
}
}
impl WebSocketEvent for ChannelDelete {}

View File

@ -20,7 +20,7 @@ use super::UpdateMessage;
#[cfg(feature = "client")]
use crate::gateway::Shared;
#[derive(Debug, Deserialize, Serialize, Default, Clone, SourceUrlField, JsonField, WebSocketEvent)]
#[derive(Debug, Deserialize, Serialize, Default, Clone, SourceUrlField, JsonField)]
/// See <https://discord.com/developers/docs/topics/gateway-events#guild-create>;
/// Received to give data about a guild;
// This one is particularly painful, it can be a Guild object with an extra field or an unavailable guild object
@ -60,7 +60,9 @@ impl Default for GuildCreateDataOption {
}
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
impl WebSocketEvent for GuildCreate {}
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#guild-ban-add-guild-ban-add-event-fields>;
/// Received to give info about a user being banned from a guild;
pub struct GuildBanAdd {
@ -68,7 +70,9 @@ pub struct GuildBanAdd {
pub user: PublicUser,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
impl WebSocketEvent for GuildBanAdd {}
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#guild-ban-remove>;
/// Received to give info about a user being unbanned from a guild;
pub struct GuildBanRemove {
@ -76,7 +80,9 @@ pub struct GuildBanRemove {
pub user: PublicUser,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, SourceUrlField, JsonField, WebSocketEvent)]
impl WebSocketEvent for GuildBanRemove {}
#[derive(Debug, Default, Deserialize, Serialize, Clone, SourceUrlField, JsonField)]
/// See <https://discord.com/developers/docs/topics/gateway-events#guild-update>;
/// Received to give info about a guild being updated;
pub struct GuildUpdate {
@ -88,6 +94,8 @@ pub struct GuildUpdate {
pub json: String,
}
impl WebSocketEvent for GuildUpdate {}
#[cfg(feature = "client")]
impl UpdateMessage<Guild> for GuildUpdate {
#[cfg(not(tarpaulin_include))]
@ -96,7 +104,7 @@ impl UpdateMessage<Guild> for GuildUpdate {
}
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, SourceUrlField, JsonField, WebSocketEvent)]
#[derive(Debug, Default, Deserialize, Serialize, Clone, SourceUrlField, JsonField)]
/// See <https://discord.com/developers/docs/topics/gateway-events#guild-delete>;
/// Received to tell the client about a guild being deleted;
pub struct GuildDelete {
@ -117,7 +125,9 @@ impl UpdateMessage<Guild> for GuildDelete {
fn update(&mut self, _: Shared<Guild>) {}
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
impl WebSocketEvent for GuildDelete {}
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#guild-audit-log-entry-create>;
/// Received to the client about an audit log entry being added;
pub struct GuildAuditLogEntryCreate {
@ -125,7 +135,9 @@ pub struct GuildAuditLogEntryCreate {
pub entry: AuditLogEntry,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
impl WebSocketEvent for GuildAuditLogEntryCreate {}
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#guild-emojis-update>;
/// Received to tell the client about a change to a guild's emoji list;
pub struct GuildEmojisUpdate {
@ -133,7 +145,9 @@ pub struct GuildEmojisUpdate {
pub emojis: Vec<Emoji>,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
impl WebSocketEvent for GuildEmojisUpdate {}
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#guild-stickers-update>;
/// Received to tell the client about a change to a guild's sticker list;
pub struct GuildStickersUpdate {
@ -141,13 +155,17 @@ pub struct GuildStickersUpdate {
pub stickers: Vec<Sticker>,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
impl WebSocketEvent for GuildStickersUpdate {}
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#guild-integrations-update>
pub struct GuildIntegrationsUpdate {
pub guild_id: Snowflake,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
impl WebSocketEvent for GuildIntegrationsUpdate {}
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#guild-member-add>;
/// Received to tell the client about a user joining a guild;
pub struct GuildMemberAdd {
@ -156,7 +174,9 @@ pub struct GuildMemberAdd {
pub guild_id: Snowflake,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
impl WebSocketEvent for GuildMemberAdd {}
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#guild-member-remove>;
/// Received to tell the client about a user leaving a guild;
pub struct GuildMemberRemove {
@ -164,7 +184,9 @@ pub struct GuildMemberRemove {
pub user: PublicUser,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
impl WebSocketEvent for GuildMemberRemove {}
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#guild-member-update>
pub struct GuildMemberUpdate {
pub guild_id: Snowflake,
@ -180,7 +202,9 @@ pub struct GuildMemberUpdate {
pub communication_disabled_until: Option<DateTime<Utc>>,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
impl WebSocketEvent for GuildMemberUpdate {}
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#guild-members-chunk>
pub struct GuildMembersChunk {
pub guild_id: Snowflake,
@ -192,7 +216,9 @@ pub struct GuildMembersChunk {
pub nonce: Option<String>,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, JsonField, SourceUrlField, WebSocketEvent)]
impl WebSocketEvent for GuildMembersChunk {}
#[derive(Debug, Default, Deserialize, Serialize, Clone, JsonField, SourceUrlField)]
/// See <https://discord.com/developers/docs/topics/gateway-events#guild-role-create>
pub struct GuildRoleCreate {
pub guild_id: Snowflake,
@ -203,6 +229,8 @@ pub struct GuildRoleCreate {
pub source_url: String,
}
impl WebSocketEvent for GuildRoleCreate {}
#[cfg(feature = "client")]
impl UpdateMessage<Guild> for GuildRoleCreate {
#[cfg(not(tarpaulin_include))]
@ -224,7 +252,7 @@ impl UpdateMessage<Guild> for GuildRoleCreate {
}
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, JsonField, SourceUrlField, WebSocketEvent)]
#[derive(Debug, Default, Deserialize, Serialize, Clone, JsonField, SourceUrlField)]
/// See <https://discord.com/developers/docs/topics/gateway-events#guild-role-update>
pub struct GuildRoleUpdate {
pub guild_id: Snowflake,
@ -235,6 +263,8 @@ pub struct GuildRoleUpdate {
pub source_url: String,
}
impl WebSocketEvent for GuildRoleUpdate {}
#[cfg(feature = "client")]
impl UpdateMessage<RoleObject> for GuildRoleUpdate {
#[cfg(not(tarpaulin_include))]
@ -248,35 +278,43 @@ impl UpdateMessage<RoleObject> for GuildRoleUpdate {
}
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#guild-role-delete>
pub struct GuildRoleDelete {
pub guild_id: Snowflake,
pub role_id: Snowflake,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
impl WebSocketEvent for GuildRoleDelete {}
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#guild-scheduled-event-create>
pub struct GuildScheduledEventCreate {
#[serde(flatten)]
pub event: GuildScheduledEvent,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
impl WebSocketEvent for GuildScheduledEventCreate {}
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#guild-scheduled-event-update>
pub struct GuildScheduledEventUpdate {
#[serde(flatten)]
pub event: GuildScheduledEvent,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
impl WebSocketEvent for GuildScheduledEventUpdate {}
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#guild-scheduled-event-delete>
pub struct GuildScheduledEventDelete {
#[serde(flatten)]
pub event: GuildScheduledEvent,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
impl WebSocketEvent for GuildScheduledEventDelete {}
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#guild-scheduled-event-user-add>
pub struct GuildScheduledEventUserAdd {
pub guild_scheduled_event_id: Snowflake,
@ -284,10 +322,14 @@ pub struct GuildScheduledEventUserAdd {
pub guild_id: Snowflake,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
impl WebSocketEvent for GuildScheduledEventUserAdd {}
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#guild-scheduled-event-user-remove>
pub struct GuildScheduledEventUserRemove {
pub guild_scheduled_event_id: Snowflake,
pub user_id: Snowflake,
pub guild_id: Snowflake,
}
impl WebSocketEvent for GuildScheduledEventUserRemove {}

View File

@ -5,14 +5,17 @@
use crate::types::events::WebSocketEvent;
use serde::{Deserialize, Serialize};
#[derive(Debug, Default, Deserialize, Serialize, WebSocketEvent)]
#[derive(Debug, Default, Deserialize, Serialize)]
pub struct GatewayHeartbeat {
pub op: u8,
pub d: Option<u64>,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
impl WebSocketEvent for GatewayHeartbeat {}
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
pub struct GatewayHeartbeatAck {
pub op: i32,
}
impl WebSocketEvent for GatewayHeartbeatAck {}

View File

@ -3,20 +3,22 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use crate::types::WebSocketEvent;
use chorus_macros::WebSocketEvent;
use serde::{Deserialize, Serialize};
/// Received on gateway init, tells the client how often to send heartbeats;
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Eq, WebSocketEvent)]
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Eq)]
pub struct GatewayHello {
pub op: i32,
pub d: HelloData,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Eq, Copy, WebSocketEvent)]
impl WebSocketEvent for GatewayHello {}
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Eq, Copy)]
/// Contains info on how often the client should send heartbeats to the server;
pub struct HelloData {
/// How often a client should send heartbeats, in milliseconds
pub heartbeat_interval: u64,
}
impl WebSocketEvent for HelloData {}

View File

@ -6,7 +6,7 @@ use crate::types::events::{PresenceUpdate, WebSocketEvent};
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, WebSocketEvent)]
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
pub struct GatewayIdentifyPayload {
pub token: String,
pub properties: GatewayIdentifyConnectionProps,
@ -70,7 +70,9 @@ impl GatewayIdentifyPayload {
}
}
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq, WebSocketEvent)]
impl WebSocketEvent for GatewayIdentifyPayload {}
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
#[serde_as]
pub struct GatewayIdentifyConnectionProps {
/// Almost always sent

View File

@ -5,9 +5,8 @@
use serde::{Deserialize, Serialize};
use crate::types::{Integration, Snowflake, WebSocketEvent};
use chorus_macros::WebSocketEvent;
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#integration-create>
pub struct IntegrationCreate {
#[serde(flatten)]
@ -15,7 +14,9 @@ pub struct IntegrationCreate {
pub guild_id: Snowflake,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
impl WebSocketEvent for IntegrationCreate {}
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#integration-update>
pub struct IntegrationUpdate {
#[serde(flatten)]
@ -23,7 +24,9 @@ pub struct IntegrationUpdate {
pub guild_id: Snowflake,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
impl WebSocketEvent for IntegrationUpdate {}
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#integration-delete>
pub struct IntegrationDelete {
pub id: Snowflake,
@ -31,3 +34,4 @@ pub struct IntegrationDelete {
pub application_id: Option<Snowflake>,
}
impl WebSocketEvent for IntegrationDelete {}

View File

@ -5,12 +5,12 @@
use serde::{Deserialize, Serialize};
use crate::types::{Interaction, WebSocketEvent};
use chorus_macros::WebSocketEvent;
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#interaction-create>
pub struct InteractionCreate {
#[serde(flatten)]
pub interaction: Interaction,
}
impl WebSocketEvent for InteractionCreate {}

View File

@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
use super::WebSocketEvent;
#[derive(Debug, Deserialize, Serialize, Default, Clone, WebSocketEvent)]
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
/// Your session is now invalid.
///
/// Either reauthenticate and reidentify or resume if possible.
@ -14,3 +14,4 @@ pub struct GatewayInvalidSession {
pub resumable: bool,
}
impl WebSocketEvent for GatewayInvalidSession {}

View File

@ -5,16 +5,17 @@
use serde::{Deserialize, Serialize};
use crate::types::{GuildInvite, Snowflake, WebSocketEvent};
use chorus_macros::WebSocketEvent;
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#invite-create>
pub struct InviteCreate {
#[serde(flatten)]
pub invite: GuildInvite,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
impl WebSocketEvent for InviteCreate {}
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#invite-delete>
pub struct InviteDelete {
pub channel_id: Snowflake,
@ -22,3 +23,4 @@ pub struct InviteDelete {
pub code: String,
}
impl WebSocketEvent for InviteDelete {}

View File

@ -7,9 +7,10 @@ use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use crate::types::Snowflake;
use super::WebSocketEvent;
#[derive(Debug, Deserialize, Serialize, Default, Clone, WebSocketEvent)]
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
/// Officially Undocumented
///
/// Sent to the server to signify lazy loading of a guild;
@ -30,3 +31,4 @@ pub struct LazyRequest {
pub channels: Option<HashMap<String, Vec<Vec<u64>>>>,
}
impl WebSocketEvent for LazyRequest {}

View File

@ -6,12 +6,12 @@ use serde::{Deserialize, Serialize};
use crate::types::{
entities::{Emoji, GuildMember, Message, PublicUser},
Snowflake, WebSocketEvent
Snowflake,
};
use chorus_macros::WebSocketEvent;
use super::WebSocketEvent;
#[derive(Debug, Deserialize, Serialize, Default, Clone, WebSocketEvent)]
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
/// # Reference
/// See <https://discord.com/developers/docs/topics/gateway-events#typing-start>
pub struct TypingStartEvent {
@ -22,7 +22,9 @@ pub struct TypingStartEvent {
pub member: Option<GuildMember>,
}
#[derive(Debug, Serialize, Deserialize, Default, Clone, WebSocketEvent)]
impl WebSocketEvent for TypingStartEvent {}
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#message-create>
pub struct MessageCreate {
#[serde(flatten)]
@ -32,7 +34,7 @@ pub struct MessageCreate {
pub mentions: Option<Vec<MessageCreateUser>>,
}
#[derive(Debug, Serialize, Deserialize, Default, Clone, WebSocketEvent)]
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#message-create-message-create-extra-fields>
pub struct MessageCreateUser {
#[serde(flatten)]
@ -40,7 +42,9 @@ pub struct MessageCreateUser {
pub member: Option<GuildMember>,
}
#[derive(Debug, Serialize, Deserialize, Default, Clone, WebSocketEvent)]
impl WebSocketEvent for MessageCreate {}
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
/// # Reference
/// See <https://discord.com/developers/docs/topics/gateway-events#message-update>
pub struct MessageUpdate {
@ -51,7 +55,9 @@ pub struct MessageUpdate {
pub mentions: Option<Vec<MessageCreateUser>>,
}
#[derive(Debug, Serialize, Deserialize, Default, Clone, WebSocketEvent)]
impl WebSocketEvent for MessageUpdate {}
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
/// # Reference
/// See <https://discord.com/developers/docs/topics/gateway-events#message-delete>
pub struct MessageDelete {
@ -60,7 +66,9 @@ pub struct MessageDelete {
pub guild_id: Option<Snowflake>,
}
#[derive(Debug, Serialize, Deserialize, Default, Clone, WebSocketEvent)]
impl WebSocketEvent for MessageDelete {}
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
/// # Reference
/// See <https://discord.com/developers/docs/topics/gateway-events#message-delete-bulk>
pub struct MessageDeleteBulk {
@ -69,7 +77,9 @@ pub struct MessageDeleteBulk {
pub guild_id: Option<Snowflake>,
}
#[derive(Debug, Serialize, Deserialize, Default, Clone, WebSocketEvent)]
impl WebSocketEvent for MessageDeleteBulk {}
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
/// # Reference
/// See <https://discord.com/developers/docs/topics/gateway-events#message-reaction-add>
pub struct MessageReactionAdd {
@ -81,7 +91,9 @@ pub struct MessageReactionAdd {
pub emoji: Emoji,
}
#[derive(Debug, Serialize, Deserialize, Default, Clone, WebSocketEvent)]
impl WebSocketEvent for MessageReactionAdd {}
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
/// # Reference
/// See <https://discord.com/developers/docs/topics/gateway-events#message-reaction-remove>
pub struct MessageReactionRemove {
@ -92,7 +104,9 @@ pub struct MessageReactionRemove {
pub emoji: Emoji,
}
#[derive(Debug, Serialize, Deserialize, Default, Clone, WebSocketEvent)]
impl WebSocketEvent for MessageReactionRemove {}
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
/// # Reference
/// See <https://discord.com/developers/docs/topics/gateway-events#message-reaction-remove-all>
pub struct MessageReactionRemoveAll {
@ -101,7 +115,9 @@ pub struct MessageReactionRemoveAll {
pub guild_id: Option<Snowflake>,
}
#[derive(Debug, Serialize, Deserialize, Default, Clone, WebSocketEvent)]
impl WebSocketEvent for MessageReactionRemoveAll {}
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
/// # Reference
/// See <https://discord.com/developers/docs/topics/gateway-events#message-reaction-remove-emoji>
pub struct MessageReactionRemoveEmoji {
@ -111,7 +127,9 @@ pub struct MessageReactionRemoveEmoji {
pub emoji: Emoji,
}
#[derive(Debug, Deserialize, Serialize, Default, Clone, WebSocketEvent)]
impl WebSocketEvent for MessageReactionRemoveEmoji {}
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
/// Officially Undocumented
///
/// Not documented anywhere unofficially
@ -132,3 +150,4 @@ pub struct MessageACK {
pub channel_id: Snowflake,
}
impl WebSocketEvent for MessageACK {}

View File

@ -33,8 +33,6 @@ pub use voice::*;
pub use voice_gateway::*;
pub use webhooks::*;
use chorus_macros::WebSocketEvent;
#[cfg(feature = "client")]
use super::Snowflake;
@ -86,7 +84,7 @@ mod voice_gateway;
pub trait WebSocketEvent: Send + Sync + Debug {}
#[derive(Debug, Default, Serialize, Clone, WebSocketEvent)]
#[derive(Debug, Default, Serialize, Clone)]
/// The payload used for sending events to the gateway
///
/// Similar to [GatewayReceivePayload], except we send a [serde_json::value::Value] for d whilst we receive a [serde_json::value::RawValue]
@ -104,6 +102,8 @@ pub struct GatewaySendPayload {
pub sequence_number: Option<u64>,
}
impl WebSocketEvent for GatewaySendPayload {}
#[derive(Debug, Default, Deserialize, Clone)]
/// The payload used for receiving events from the gateway
pub struct GatewayReceivePayload<'a> {

View File

@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
use super::{ChannelUnreadUpdateObject, WebSocketEvent};
use crate::types::{GuildMember, Snowflake, VoiceState};
#[derive(Debug, Deserialize, Serialize, Default, WebSocketEvent)]
#[derive(Debug, Deserialize, Serialize, Default)]
/// Officially Undocumented
///
/// Seems to be passively set to update the client on guild details (though, why not just send the update events?)
@ -18,3 +18,4 @@ pub struct PassiveUpdateV1 {
pub channels: Vec<ChannelUnreadUpdateObject>,
}
impl WebSocketEvent for PassiveUpdateV1 {}

View File

@ -6,7 +6,7 @@ use crate::types::{events::WebSocketEvent, UserStatus};
use crate::types::{Activity, ClientStatusObject, PublicUser, Snowflake};
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize, Default, Clone, WebSocketEvent)]
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
/// Sent by the client to update its status and presence;
/// See <https://discord.com/developers/docs/topics/gateway-events#update-presence>
pub struct UpdatePresence {
@ -18,7 +18,7 @@ pub struct UpdatePresence {
pub afk: bool,
}
#[derive(Debug, Deserialize, Serialize, Default, Clone, PartialEq, WebSocketEvent)]
#[derive(Debug, Deserialize, Serialize, Default, Clone, PartialEq)]
/// Received to tell the client that a user updated their presence / status
/// See <https://discord.com/developers/docs/topics/gateway-events#presence-update-presence-update-event-fields>
pub struct PresenceUpdate {
@ -30,3 +30,4 @@ pub struct PresenceUpdate {
pub client_status: ClientStatusObject,
}
impl WebSocketEvent for PresenceUpdate {}

View File

@ -9,7 +9,7 @@ use crate::types::events::{Session, WebSocketEvent};
use crate::types::interfaces::ClientStatusObject;
use crate::types::{Activity, GuildMember, PresenceUpdate, VoiceState};
#[derive(Debug, Deserialize, Serialize, Default, Clone, WebSocketEvent)]
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
/// 1/2 half documented;
/// Received after identifying, provides initial user info;
/// See <https://discord.com/developers/docs/topics/gateway-events#ready;>
@ -30,7 +30,9 @@ pub struct GatewayReady {
pub shard: Option<(u64, u64)>,
}
#[derive(Debug, Deserialize, Serialize, Default, Clone, WebSocketEvent)]
impl WebSocketEvent for GatewayReady {}
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
/// Officially Undocumented;
/// Sent after the READY event when a client is a user, seems to somehow add onto the ready event;
pub struct GatewayReadySupplemental {
@ -43,6 +45,8 @@ pub struct GatewayReadySupplemental {
pub disclose: Vec<String>,
}
impl WebSocketEvent for GatewayReadySupplemental {}
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
pub struct MergedPresences {
pub guilds: Vec<Vec<MergedPresenceGuild>>,

View File

@ -2,10 +2,11 @@ use serde::{Deserialize, Serialize};
use super::WebSocketEvent;
#[derive(Debug, Deserialize, Serialize, Default, Clone, WebSocketEvent)]
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
/// "The reconnect event is dispatched when a client should reconnect to the Gateway (and resume their existing session, if they have one). This event usually occurs during deploys to migrate sessions gracefully off old hosts"
///
/// # Reference
/// See <https://docs.discord.sex/topics/gateway-events#reconnect>
pub struct GatewayReconnect {}
impl WebSocketEvent for GatewayReconnect {}

View File

@ -5,7 +5,7 @@
use crate::types::{events::WebSocketEvent, Relationship, RelationshipType, Snowflake};
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize, Default, WebSocketEvent)]
#[derive(Debug, Deserialize, Serialize, Default)]
/// See <https://github.com/spacebarchat/server/issues/204>
pub struct RelationshipAdd {
#[serde(flatten)]
@ -13,7 +13,9 @@ pub struct RelationshipAdd {
pub should_notify: bool,
}
#[derive(Debug, Deserialize, Serialize, Default, Clone, WebSocketEvent)]
impl WebSocketEvent for RelationshipAdd {}
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
/// See <https://github.com/spacebarchat/server/issues/203>
pub struct RelationshipRemove {
pub id: Snowflake,
@ -21,3 +23,4 @@ pub struct RelationshipRemove {
pub relationship_type: RelationshipType,
}
impl WebSocketEvent for RelationshipRemove {}

View File

@ -5,7 +5,7 @@
use crate::types::{events::WebSocketEvent, Snowflake};
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize, Default, WebSocketEvent)]
#[derive(Debug, Deserialize, Serialize, Default)]
/// See <https://discord.com/developers/docs/topics/gateway-events#request-guild-members-request-guild-members-structure>
pub struct GatewayRequestGuildMembers {
pub guild_id: Snowflake,
@ -17,3 +17,4 @@ pub struct GatewayRequestGuildMembers {
pub nonce: Option<String>,
}
impl WebSocketEvent for GatewayRequestGuildMembers {}

View File

@ -5,10 +5,11 @@
use crate::types::events::WebSocketEvent;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Deserialize, Serialize, Default, WebSocketEvent)]
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
pub struct GatewayResume {
pub token: String,
pub session_id: String,
pub seq: String,
}
impl WebSocketEvent for GatewayResume {}

View File

@ -2,12 +2,11 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use chorus_macros::WebSocketEvent;
use serde::{Deserialize, Serialize};
use crate::types::{Activity, WebSocketEvent};
#[derive(Debug, Deserialize, Serialize, Default, Clone, WebSocketEvent)]
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
/// Officially Undocumented
/// Seems like it sends active session info to users on connect
/// [{"activities":[],"client_info":{"client":"web","os":"other","version":0},"session_id":"ab5941b50d818b1f8d93b4b1b581b192","status":"online"}]
@ -34,3 +33,4 @@ pub struct ClientInfo {
pub version: u8,
}
impl WebSocketEvent for SessionsReplace {}

View File

@ -5,26 +5,30 @@
use serde::{Deserialize, Serialize};
use crate::types::{StageInstance, WebSocketEvent};
use chorus_macros::WebSocketEvent;
#[derive(Debug, Deserialize, Serialize, Default, Clone, WebSocketEvent)]
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#stage-instance-create>
pub struct StageInstanceCreate {
#[serde(flatten)]
pub stage_instance: StageInstance,
}
#[derive(Debug, Deserialize, Serialize, Default, Clone, WebSocketEvent)]
impl WebSocketEvent for StageInstanceCreate {}
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#stage-instance-update>
pub struct StageInstanceUpdate {
#[serde(flatten)]
pub stage_instance: StageInstance,
}
#[derive(Debug, Deserialize, Serialize, Default, Clone, WebSocketEvent)]
impl WebSocketEvent for StageInstanceUpdate {}
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#stage-instance-delete>
pub struct StageInstanceDelete {
#[serde(flatten)]
pub stage_instance: StageInstance,
}
impl WebSocketEvent for StageInstanceDelete {}

View File

@ -12,14 +12,16 @@ use crate::types::{JsonField, Snowflake, SourceUrlField};
#[cfg(feature = "client")]
use super::UpdateMessage;
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#thread-create>
pub struct ThreadCreate {
#[serde(flatten)]
pub thread: Channel,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, JsonField, SourceUrlField, WebSocketEvent)]
impl WebSocketEvent for ThreadCreate {}
#[derive(Debug, Default, Deserialize, Serialize, Clone, JsonField, SourceUrlField)]
/// See <https://discord.com/developers/docs/topics/gateway-events#thread-update>
pub struct ThreadUpdate {
#[serde(flatten)]
@ -30,6 +32,8 @@ pub struct ThreadUpdate {
pub source_url: String,
}
impl WebSocketEvent for ThreadUpdate {}
#[cfg(feature = "client")]
impl UpdateMessage<Channel> for ThreadUpdate {
#[cfg(not(tarpaulin_include))]
@ -38,14 +42,16 @@ impl UpdateMessage<Channel> for ThreadUpdate {
}
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#thread-delete>
pub struct ThreadDelete {
#[serde(flatten)]
pub thread: Channel,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
impl WebSocketEvent for ThreadDelete {}
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#thread-list-sync>
pub struct ThreadListSync {
pub guild_id: Snowflake,
@ -54,7 +60,9 @@ pub struct ThreadListSync {
pub members: Option<Vec<ThreadMember>>,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
impl WebSocketEvent for ThreadListSync {}
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#thread-member-update>
/// The inner payload is a thread member object with an extra field.
pub struct ThreadMemberUpdate {
@ -63,7 +71,9 @@ pub struct ThreadMemberUpdate {
pub guild_id: Snowflake,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, WebSocketEvent)]
impl WebSocketEvent for ThreadMemberUpdate {}
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#thread-members-update>
pub struct ThreadMembersUpdate {
pub id: Snowflake,
@ -74,3 +84,4 @@ pub struct ThreadMembersUpdate {
pub removed_members: Option<Vec<Snowflake>>,
}
impl WebSocketEvent for ThreadMembersUpdate {}

View File

@ -8,7 +8,7 @@ use crate::types::entities::PublicUser;
use crate::types::events::WebSocketEvent;
use crate::types::utils::Snowflake;
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Eq, WebSocketEvent)]
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Eq)]
/// See <https://discord.com/developers/docs/topics/gateway-events#user-update>;
/// Sent to indicate updates to a user object; (name changes, discriminator changes, etc);
pub struct UserUpdate {
@ -16,7 +16,9 @@ pub struct UserUpdate {
pub user: PublicUser,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Eq, WebSocketEvent)]
impl WebSocketEvent for UserUpdate {}
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Eq)]
/// Undocumented;
///
/// Possibly an update for muted guild / channel settings for the current user;
@ -39,6 +41,8 @@ pub struct UserGuildSettingsUpdate {
pub channel_overrides: Vec<UserGuildSettingsChannelOverride>,
}
impl WebSocketEvent for UserGuildSettingsUpdate {}
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Eq)]
/// Undocumented;
///

View File

@ -5,7 +5,7 @@
use crate::types::{events::WebSocketEvent, Snowflake, VoiceState};
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize, Default, Clone, Copy, PartialEq, Eq, WebSocketEvent)]
#[derive(Debug, Deserialize, Serialize, Default, Clone, Copy, PartialEq, Eq)]
///
/// Sent to the server to indicate an update of the voice state (leave voice channel, join voice channel, mute, deafen);
///
@ -17,7 +17,9 @@ pub struct UpdateVoiceState {
pub self_deaf: bool,
}
#[derive(Debug, Deserialize, Serialize, Default, Clone, WebSocketEvent)]
impl WebSocketEvent for UpdateVoiceState {}
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#voice-state-update>;
///
/// Received from the server to indicate an update in a user's voice state (leave voice channel, join voice channel, mute, deafen, etc);
@ -28,7 +30,9 @@ pub struct VoiceStateUpdate {
pub state: VoiceState,
}
#[derive(Debug, Deserialize, Serialize, Default, Clone, PartialEq, Eq, WebSocketEvent)]
impl WebSocketEvent for VoiceStateUpdate {}
#[derive(Debug, Deserialize, Serialize, Default, Clone, PartialEq, Eq)]
/// See <https://discord.com/developers/docs/topics/gateway-events#voice-server-update>;
///
/// Received to indicate which voice endpoint, token and guild_id to use;
@ -41,3 +45,4 @@ pub struct VoiceServerUpdate {
pub endpoint: Option<String>,
}
impl WebSocketEvent for VoiceServerUpdate {}

View File

@ -3,10 +3,9 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use crate::types::{Snowflake, WebSocketEvent};
use chorus_macros::WebSocketEvent;
use serde::{Deserialize, Serialize};
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Copy, WebSocketEvent)]
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Copy)]
/// Sent when another user connects to the voice server.
///
/// Contains the user id and "flags".
@ -22,7 +21,9 @@ pub struct VoiceClientConnectFlags {
pub flags: Option<u8>,
}
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Copy, WebSocketEvent)]
impl WebSocketEvent for VoiceClientConnectFlags {}
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Copy)]
/// Sent when another user connects to the voice server.
///
/// Contains the user id and "platform".
@ -36,3 +37,4 @@ pub struct VoiceClientConnectPlatform {
pub platform: u8,
}
impl WebSocketEvent for VoiceClientConnectPlatform {}

View File

@ -3,10 +3,9 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use crate::types::{Snowflake, WebSocketEvent};
use chorus_macros::WebSocketEvent;
use serde::{Deserialize, Serialize};
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Copy, WebSocketEvent)]
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Copy)]
/// Sent when another user disconnects from the voice server.
///
/// When received, the SSRC of the user should be discarded.
@ -16,3 +15,4 @@ pub struct VoiceClientDisconnection {
pub user_id: Snowflake,
}
impl WebSocketEvent for VoiceClientDisconnection {}

View File

@ -3,10 +3,9 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use crate::types::WebSocketEvent;
use chorus_macros::WebSocketEvent;
use serde::{Deserialize, Serialize};
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Copy, WebSocketEvent)]
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Copy)]
/// Contains info on how often the client should send heartbeats to the server;
///
/// Differs from the normal hello data in that discord sends heartbeat interval as a float.
@ -22,3 +21,4 @@ pub struct VoiceHelloData {
pub heartbeat_interval: f64,
}
impl WebSocketEvent for VoiceHelloData {}

View File

@ -3,10 +3,9 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use crate::types::{Snowflake, WebSocketEvent};
use chorus_macros::WebSocketEvent;
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize, Default, Clone, PartialEq, Eq, WebSocketEvent)]
#[derive(Debug, Deserialize, Serialize, Default, Clone, PartialEq, Eq)]
/// The identify payload for the voice gateway connection;
///
/// Contains authentication info and context to authenticate to the voice gateway.
@ -23,3 +22,4 @@ pub struct VoiceIdentify {
// TODO: Add video streams
}
impl WebSocketEvent for VoiceIdentify {}

View File

@ -3,10 +3,9 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use crate::types::WebSocketEvent;
use chorus_macros::WebSocketEvent;
use serde::{Deserialize, Serialize};
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Copy, WebSocketEvent)]
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Copy)]
/// What does this do?
///
/// {"op":15,"d":{"any":100}}
@ -16,3 +15,4 @@ pub struct VoiceMediaSinkWants {
pub any: u16,
}
impl WebSocketEvent for VoiceMediaSinkWants {}

View File

@ -30,7 +30,7 @@ mod speaking;
mod ssrc_definition;
mod voice_backend_version;
#[derive(Debug, Default, Serialize, Clone, WebSocketEvent)]
#[derive(Debug, Default, Serialize, Clone)]
/// The payload used for sending events to the voice gateway.
///
/// Similar to [VoiceGatewayReceivePayload], except we send a [Value] for d whilst we receive a [serde_json::value::RawValue]
@ -42,6 +42,8 @@ pub struct VoiceGatewaySendPayload {
pub data: Value,
}
impl WebSocketEvent for VoiceGatewaySendPayload {}
#[derive(Debug, Deserialize, Clone)]
/// The payload used for receiving events from the voice gateway.
///

View File

@ -5,12 +5,11 @@
use std::net::Ipv4Addr;
use crate::types::WebSocketEvent;
use chorus_macros::WebSocketEvent;
use serde::{Deserialize, Serialize};
use super::VoiceEncryptionMode;
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq, WebSocketEvent)]
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
/// The voice gateway's ready event;
///
/// Gives the user info about the UDP connection IP and port, srrc to use,
@ -44,3 +43,4 @@ impl Default for VoiceReady {
}
}
impl WebSocketEvent for VoiceReady {}

View File

@ -1,9 +1,8 @@
use super::{AudioCodec, VideoCodec, VoiceEncryptionMode};
use crate::types::WebSocketEvent;
use chorus_macros::WebSocketEvent;
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize, Clone, Default, WebSocketEvent)]
#[derive(Debug, Deserialize, Serialize, Clone, Default)]
/// Event that describes our encryption mode and secret key for encryption
///
/// See <https://discord-userdoccers.vercel.app/topics/voice-connections#session-description-structure>
@ -20,7 +19,9 @@ pub struct SessionDescription {
pub keyframe_interval: Option<u64>,
}
#[derive(Debug, Deserialize, Serialize, Clone, Default, WebSocketEvent)]
impl WebSocketEvent for SessionDescription {}
#[derive(Debug, Deserialize, Serialize, Clone, Default)]
/// Event that might be sent to update session parameters
///
/// See <https://discord-userdoccers.vercel.app/topics/voice-connections#session-update-structure>
@ -35,3 +36,4 @@ pub struct SessionUpdate {
pub new_media_session_id: Option<String>,
}
impl WebSocketEvent for SessionUpdate {}

View File

@ -6,14 +6,13 @@ use bitflags::bitflags;
use serde::{Deserialize, Serialize};
use crate::types::{Snowflake, WebSocketEvent};
use chorus_macros::WebSocketEvent;
/// Event that tells the server we are speaking;
///
/// Essentially, what allows us to send UDP data and lights up the green circle around your avatar.
///
/// See <https://discord-userdoccers.vercel.app/topics/voice-connections#speaking-structure>
#[derive(Debug, Deserialize, Serialize, Clone, Default, WebSocketEvent)]
#[derive(Debug, Deserialize, Serialize, Clone, Default)]
pub struct Speaking {
/// Data about the audio we're transmitting.
///
@ -28,6 +27,8 @@ pub struct Speaking {
pub delay: u64,
}
impl WebSocketEvent for Speaking {}
bitflags! {
/// Bitflags of speaking types;
///

View File

@ -3,7 +3,6 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use crate::types::{Snowflake, WebSocketEvent};
use chorus_macros::WebSocketEvent;
use serde::{Deserialize, Serialize};
/// Defines an event which provides ssrcs for voice and video for a user id.
@ -25,7 +24,7 @@ use serde::{Deserialize, Serialize};
/// ```json
/// {"op":12,"d":{"audio_ssrc":2307250864,"video_ssrc":0,"rtx_ssrc":0,"streams":[{"type":"video","rid":"100","ssrc":26595,"active":false,"quality":100,"rtx_ssrc":26596,"max_bitrate":2500000,"max_framerate":30,"max_resolution":{"type":"fixed","width":1280,"height":720}}]}}
/// ```
#[derive(Debug, Deserialize, Serialize, Default, Clone, PartialEq, Eq, WebSocketEvent)]
#[derive(Debug, Deserialize, Serialize, Default, Clone, PartialEq, Eq)]
pub struct SsrcDefinition {
/// The ssrc used for video communications.
///
@ -51,3 +50,4 @@ pub struct SsrcDefinition {
pub streams: Vec<String>,
}
impl WebSocketEvent for SsrcDefinition {}

View File

@ -3,10 +3,9 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use crate::types::WebSocketEvent;
use chorus_macros::WebSocketEvent;
use serde::{Deserialize, Serialize};
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, WebSocketEvent)]
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq)]
/// Received from the voice gateway server to describe the backend version.
///
/// See <https://discord-userdoccers.vercel.app/topics/voice-connections#voice-backend-version>
@ -19,3 +18,4 @@ pub struct VoiceBackendVersion {
pub rtc_worker_version: String,
}
impl WebSocketEvent for VoiceBackendVersion {}

View File

@ -4,13 +4,15 @@
use serde::{Deserialize, Serialize};
use crate::types::{Snowflake, WebSocketEvent};
use chorus_macros::WebSocketEvent;
use crate::types::Snowflake;
#[derive(Debug, Deserialize, Serialize, Default, Clone, WebSocketEvent)]
use super::WebSocketEvent;
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
/// See <https://discord.com/developers/docs/topics/gateway-events#webhooks-update>
pub struct WebhooksUpdate {
pub guild_id: Snowflake,
pub channel_id: Snowflake,
}
impl WebSocketEvent for WebhooksUpdate {}