-
-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(model, gateway): add support for VOICE_CHANNEL_EFFECT_SEND
event
#2187
Draft
suneettipirneni
wants to merge
1
commit into
twilight-rs:main
Choose a base branch
from
suneettipirneni:feat/voice-channel-effects
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
114 changes: 114 additions & 0 deletions
114
twilight-model/src/gateway/payload/incoming/voice_channel_effect_send.rs
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,114 @@ | ||
use crate::{ | ||
guild::Emoji, | ||
id::{ | ||
marker::{ChannelMarker, GuildMarker, UserMarker}, | ||
Id, | ||
}, | ||
}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Sent when someone sends an effect, such as an emoji reaction, in a voice channel the current user is connected to. | ||
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] | ||
pub struct VoiceChannelEffectSend { | ||
/// The ID of the emoji animation, for emoji reaction effects | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub animation_id: Option<u64>, | ||
/// The type of emoji animation, for emoji reaction effects. | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub animation_type: Option<VoiceChannelEffectAnimationType>, | ||
/// ID of the channel the effect was sent in. | ||
pub channel_id: Id<ChannelMarker>, | ||
/// The emoji sent, for emoji reaction effects. | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub emoji: Option<Emoji>, | ||
/// ID of the guild the effect was sent in. | ||
pub guild_id: Id<GuildMarker>, | ||
/// ID of the user who sent the effect | ||
pub user_id: Id<UserMarker>, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] | ||
pub enum VoiceChannelEffectAnimationType { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Always has to place items, should this be under the |
||
/// A fun animation, sent by a Nitro subscriber. | ||
Premium, | ||
/// The standard animation. | ||
Basic, | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::{VoiceChannelEffectAnimationType, VoiceChannelEffectSend}; | ||
use crate::{guild::Emoji, id::Id}; | ||
use serde_test::Token; | ||
|
||
#[test] | ||
fn voice_channel_effect_send() { | ||
let value = VoiceChannelEffectSend { | ||
animation_id: Some(42), | ||
animation_type: Some(VoiceChannelEffectAnimationType::Premium), | ||
channel_id: Id::new(1), | ||
emoji: Some(Emoji { | ||
animated: true, | ||
available: true, | ||
id: Id::new(6), | ||
managed: true, | ||
name: "test".to_string(), | ||
require_colons: true, | ||
roles: vec![], | ||
user: None, | ||
}), | ||
guild_id: Id::new(42), | ||
user_id: Id::new(24), | ||
}; | ||
|
||
serde_test::assert_tokens( | ||
&value, | ||
&[ | ||
Token::Struct { | ||
name: "VoiceChannelEffectSend", | ||
len: 6, | ||
}, | ||
Token::Str("animation_id"), | ||
Token::Some, | ||
Token::U64(42), | ||
Token::Str("animation_type"), | ||
Token::Some, | ||
Token::Enum { | ||
name: "VoiceChannelEffectAnimationType", | ||
}, | ||
Token::Str("Premium"), | ||
Token::Unit, | ||
Token::Str("channel_id"), | ||
Token::NewtypeStruct { name: "Id" }, | ||
Token::Str("1"), | ||
Token::Str("emoji"), | ||
Token::Some, | ||
Token::Struct { | ||
name: "Emoji", | ||
len: 6, | ||
}, | ||
Token::Str("animated"), | ||
Token::Bool(true), | ||
Token::Str("available"), | ||
Token::Bool(true), | ||
Token::Str("id"), | ||
Token::NewtypeStruct { name: "Id" }, | ||
Token::Str("6"), | ||
Token::Str("managed"), | ||
Token::Bool(true), | ||
Token::Str("name"), | ||
Token::Str("test"), | ||
Token::Str("require_colons"), | ||
Token::Bool(true), | ||
Token::StructEnd, | ||
Token::Str("guild_id"), | ||
Token::NewtypeStruct { name: "Id" }, | ||
Token::Str("42"), | ||
Token::Str("user_id"), | ||
Token::NewtypeStruct { name: "Id" }, | ||
Token::Str("24"), | ||
Token::StructEnd, | ||
], | ||
) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra space