twilight_model/application/interaction/mod.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917
//! Used when receiving interactions through gateway or webhooks.
//!
//! See [Discord Docs/Receiving and Responding].
//!
//! [Discord Docs/Receiving and Responding]: https://discord.com/developers/docs/interactions/receiving-and-responding
pub mod application_command;
pub mod message_component;
pub mod modal;
mod context_type;
mod interaction_type;
mod metadata;
mod resolved;
pub use self::{
context_type::InteractionContextType,
interaction_type::InteractionType,
metadata::InteractionMetadata,
resolved::{InteractionChannel, InteractionDataResolved, InteractionMember},
};
use self::{
application_command::CommandData, message_component::MessageComponentInteractionData,
modal::ModalInteractionData,
};
use crate::{
channel::{Channel, Message},
guild::{GuildFeature, PartialMember, Permissions},
id::{
marker::{ApplicationMarker, ChannelMarker, GuildMarker, InteractionMarker, UserMarker},
AnonymizableId, Id,
},
oauth::ApplicationIntegrationMap,
user::User,
};
use serde::{
de::{Error as DeError, IgnoredAny, MapAccess, Visitor},
Deserialize, Deserializer, Serialize,
};
use serde_value::{DeserializerError, Value};
use std::fmt::{Formatter, Result as FmtResult};
use super::monetization::Entitlement;
/// Payload received when a user executes an interaction.
///
/// See [Discord Docs/Interaction Object].
///
/// [Discord Docs/Interaction Object]: https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-structure
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct Interaction {
/// App's permissions in the channel the interaction was sent from.
#[serde(skip_serializing_if = "Option::is_none")]
pub app_permissions: Option<Permissions>,
/// ID of the associated application.
pub application_id: Id<ApplicationMarker>,
/// Mapping of installation contexts that the interaction was
/// authorized for to related user or guild IDs.
pub authorizing_integration_owners:
ApplicationIntegrationMap<AnonymizableId<GuildMarker>, Id<UserMarker>>,
/// The channel the interaction was invoked in.
///
/// Present on all interactions types, except [`Ping`].
///
/// [`Ping`]: InteractionType::Ping
#[serde(skip_serializing_if = "Option::is_none")]
pub channel: Option<Channel>,
/// ID of the channel the interaction was invoked in.
///
/// Present on all interactions types, except [`Ping`].
///
/// [`Ping`]: InteractionType::Ping
#[serde(skip_serializing_if = "Option::is_none")]
#[deprecated(
note = "channel_id is deprecated in the discord API and will no be sent in the future, users should use the channel field instead."
)]
pub channel_id: Option<Id<ChannelMarker>>,
/// Context where the interaction was triggered from.
#[serde(skip_serializing_if = "Option::is_none")]
pub context: Option<InteractionContextType>,
/// Data from the interaction.
///
/// This field present on [`ApplicationCommand`], [`MessageComponent`],
/// [`ApplicationCommandAutocomplete`] and [`ModalSubmit`] interactions.
/// The inner enum variant matches the interaction type.
///
/// [`ApplicationCommand`]: InteractionType::ApplicationCommand
/// [`MessageComponent`]: InteractionType::MessageComponent
/// [`ApplicationCommandAutocomplete`]: InteractionType::ApplicationCommandAutocomplete
/// [`ModalSubmit`]: InteractionType::ModalSubmit
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option<InteractionData>,
/// For monetized apps, any entitlements for the invoking user, representing access to premium SKUs
pub entitlements: Vec<Entitlement>,
/// Guild that the interaction was sent from.
#[serde(skip_serializing_if = "Option::is_none")]
pub guild: Option<InteractionPartialGuild>,
/// ID of the guild the interaction was invoked in.
#[serde(skip_serializing_if = "Option::is_none")]
pub guild_id: Option<Id<GuildMarker>>,
/// Guild’s preferred locale.
///
/// Present when the interaction is invoked in a guild.
#[serde(skip_serializing_if = "Option::is_none")]
pub guild_locale: Option<String>,
/// ID of the interaction.
pub id: Id<InteractionMarker>,
/// Type of interaction.
#[serde(rename = "type")]
pub kind: InteractionType,
/// Selected language of the user who invoked the interaction.
///
/// Present on all interactions types, except [`Ping`].
///
/// [`Ping`]: InteractionType::Ping
#[serde(skip_serializing_if = "Option::is_none")]
pub locale: Option<String>,
/// Member that invoked the interaction.
///
/// Present when the interaction is invoked in a guild.
#[serde(skip_serializing_if = "Option::is_none")]
pub member: Option<PartialMember>,
/// Message attached to the interaction.
///
/// Present on [`MessageComponent`] interactions.
///
/// [`MessageComponent`]: InteractionType::MessageComponent
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<Message>,
/// Token for responding to the interaction.
pub token: String,
/// User that invoked the interaction.
///
/// Present when the interaction is invoked in a direct message.
#[serde(skip_serializing_if = "Option::is_none")]
pub user: Option<User>,
}
impl Interaction {
/// ID of the user that invoked the interaction.
///
/// This will first check for the [`member`]'s
/// [`user`][`PartialMember::user`]'s ID and then, if not present, check the
/// [`user`]'s ID.
///
/// [`member`]: Self::member
/// [`user`]: Self::user
pub const fn author_id(&self) -> Option<Id<UserMarker>> {
if let Some(user) = self.author() {
Some(user.id)
} else {
None
}
}
/// The user that invoked the interaction.
///
/// This will first check for the [`member`]'s
/// [`user`][`PartialMember::user`] and then, if not present, check the
/// [`user`].
///
/// [`member`]: Self::member
/// [`user`]: Self::user
pub const fn author(&self) -> Option<&User> {
match self.member.as_ref() {
Some(member) if member.user.is_some() => member.user.as_ref(),
_ => self.user.as_ref(),
}
}
/// Whether the interaction was invoked in a DM.
pub const fn is_dm(&self) -> bool {
self.user.is_some()
}
/// Whether the interaction was invoked in a guild.
pub const fn is_guild(&self) -> bool {
self.member.is_some()
}
}
impl<'de> Deserialize<'de> for Interaction {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
deserializer.deserialize_map(InteractionVisitor)
}
}
#[derive(Debug, Deserialize)]
#[serde(field_identifier, rename_all = "snake_case")]
enum InteractionField {
AppPermissions,
ApplicationId,
Context,
Channel,
ChannelId,
Data,
Entitlements,
Guild,
GuildId,
GuildLocale,
Id,
Locale,
Member,
Message,
Token,
Type,
User,
Version,
AuthorizingIntegrationOwners,
}
struct InteractionVisitor;
impl<'de> Visitor<'de> for InteractionVisitor {
type Value = Interaction;
fn expecting(&self, f: &mut Formatter<'_>) -> FmtResult {
f.write_str("enum Interaction")
}
#[allow(clippy::too_many_lines, deprecated)]
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let mut app_permissions: Option<Permissions> = None;
let mut application_id: Option<Id<ApplicationMarker>> = None;
let mut channel: Option<Channel> = None;
let mut channel_id: Option<Id<ChannelMarker>> = None;
let mut context: Option<InteractionContextType> = None;
let mut data: Option<Value> = None;
let mut entitlements: Option<Vec<Entitlement>> = None;
let mut guild: Option<InteractionPartialGuild> = None;
let mut guild_id: Option<Id<GuildMarker>> = None;
let mut guild_locale: Option<String> = None;
let mut id: Option<Id<InteractionMarker>> = None;
let mut kind: Option<InteractionType> = None;
let mut locale: Option<String> = None;
let mut member: Option<PartialMember> = None;
let mut message: Option<Message> = None;
let mut token: Option<String> = None;
let mut user: Option<User> = None;
let mut authorizing_integration_owners: Option<
ApplicationIntegrationMap<AnonymizableId<GuildMarker>, Id<UserMarker>>,
> = None;
loop {
let key = match map.next_key() {
Ok(Some(key)) => key,
Ok(None) => break,
Err(_) => {
map.next_value::<IgnoredAny>()?;
continue;
}
};
match key {
InteractionField::AppPermissions => {
if app_permissions.is_some() {
return Err(DeError::duplicate_field("app_permissions"));
}
app_permissions = map.next_value()?;
}
InteractionField::ApplicationId => {
if application_id.is_some() {
return Err(DeError::duplicate_field("application_id"));
}
application_id = Some(map.next_value()?);
}
InteractionField::Context => {
if context.is_some() {
return Err(DeError::duplicate_field("context"));
}
context = map.next_value()?;
}
InteractionField::Channel => {
if channel.is_some() {
return Err(DeError::duplicate_field("channel"));
}
channel = map.next_value()?;
}
InteractionField::ChannelId => {
if channel_id.is_some() {
return Err(DeError::duplicate_field("channel_id"));
}
channel_id = map.next_value()?;
}
InteractionField::Data => {
if data.is_some() {
return Err(DeError::duplicate_field("data"));
}
data = map.next_value()?;
}
InteractionField::Entitlements => {
if entitlements.is_some() {
return Err(DeError::duplicate_field("entitlements"));
}
entitlements = map.next_value()?;
}
InteractionField::Guild => {
if guild.is_some() {
return Err(DeError::duplicate_field("guild"));
}
guild = map.next_value()?;
}
InteractionField::GuildId => {
if guild_id.is_some() {
return Err(DeError::duplicate_field("guild_id"));
}
guild_id = map.next_value()?;
}
InteractionField::GuildLocale => {
if guild_locale.is_some() {
return Err(DeError::duplicate_field("guild_locale"));
}
guild_locale = map.next_value()?;
}
InteractionField::Id => {
if id.is_some() {
return Err(DeError::duplicate_field("id"));
}
id = Some(map.next_value()?);
}
InteractionField::Locale => {
if locale.is_some() {
return Err(DeError::duplicate_field("locale"));
}
locale = map.next_value()?;
}
InteractionField::Member => {
if member.is_some() {
return Err(DeError::duplicate_field("member"));
}
member = map.next_value()?;
}
InteractionField::Message => {
if message.is_some() {
return Err(DeError::duplicate_field("message"));
}
message = map.next_value()?;
}
InteractionField::Token => {
if token.is_some() {
return Err(DeError::duplicate_field("token"));
}
token = Some(map.next_value()?);
}
InteractionField::Type => {
if kind.is_some() {
return Err(DeError::duplicate_field("kind"));
}
kind = Some(map.next_value()?);
}
InteractionField::User => {
if user.is_some() {
return Err(DeError::duplicate_field("user"));
}
user = map.next_value()?;
}
InteractionField::Version => {
// Ignoring the version field.
map.next_value::<IgnoredAny>()?;
}
InteractionField::AuthorizingIntegrationOwners => {
if authorizing_integration_owners.is_some() {
return Err(DeError::duplicate_field("authorizing_integration_owners"));
}
authorizing_integration_owners = map.next_value()?;
}
}
}
let application_id =
application_id.ok_or_else(|| DeError::missing_field("application_id"))?;
let authorizing_integration_owners = authorizing_integration_owners
.ok_or_else(|| DeError::missing_field("authorizing_integration_owners"))?;
let id = id.ok_or_else(|| DeError::missing_field("id"))?;
let token = token.ok_or_else(|| DeError::missing_field("token"))?;
let kind = kind.ok_or_else(|| DeError::missing_field("kind"))?;
let data = match kind {
InteractionType::Ping => None,
InteractionType::ApplicationCommand => {
let data = data
.ok_or_else(|| DeError::missing_field("data"))?
.deserialize_into()
.map_err(DeserializerError::into_error)?;
Some(InteractionData::ApplicationCommand(data))
}
InteractionType::MessageComponent => {
let data = data
.ok_or_else(|| DeError::missing_field("data"))?
.deserialize_into()
.map_err(DeserializerError::into_error)?;
Some(InteractionData::MessageComponent(data))
}
InteractionType::ApplicationCommandAutocomplete => {
let data = data
.ok_or_else(|| DeError::missing_field("data"))?
.deserialize_into()
.map_err(DeserializerError::into_error)?;
Some(InteractionData::ApplicationCommand(data))
}
InteractionType::ModalSubmit => {
let data = data
.ok_or_else(|| DeError::missing_field("data"))?
.deserialize_into()
.map_err(DeserializerError::into_error)?;
Some(InteractionData::ModalSubmit(data))
}
};
let entitlements = entitlements.unwrap_or_default();
Ok(Self::Value {
app_permissions,
application_id,
authorizing_integration_owners,
channel,
channel_id,
context,
data,
entitlements,
guild,
guild_id,
guild_locale,
id,
kind,
locale,
member,
message,
token,
user,
})
}
}
/// Additional [`Interaction`] data, such as the invoking user.
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[non_exhaustive]
#[serde(untagged)]
pub enum InteractionData {
/// Data received for the [`ApplicationCommand`] and [`ApplicationCommandAutocomplete`]
/// interaction types.
///
/// [`ApplicationCommand`]: InteractionType::ApplicationCommand
/// [`ApplicationCommandAutocomplete`]: InteractionType::ApplicationCommandAutocomplete
ApplicationCommand(Box<CommandData>),
/// Data received for the [`MessageComponent`] interaction type.
///
/// [`MessageComponent`]: InteractionType::MessageComponent
MessageComponent(Box<MessageComponentInteractionData>),
/// Data received for the [`ModalSubmit`] interaction type.
///
/// [`ModalSubmit`]: InteractionType::ModalSubmit
ModalSubmit(ModalInteractionData),
}
/// Partial guild containing only the fields sent in the partial guild
/// in interactions.
///
/// # Note that the field `locale` does not exists on the full guild
/// object, and is only found here. See
/// <https://github.com/discord/discord-api-docs/issues/6938> for more
/// info.
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize, Hash)]
pub struct InteractionPartialGuild {
/// Id of the guild.
pub id: Option<Id<GuildMarker>>,
/// Enabled guild features
pub features: Option<Vec<GuildFeature>>,
pub locale: Option<String>,
}
#[cfg(test)]
mod tests {
use super::{
application_command::{CommandData, CommandDataOption, CommandOptionValue},
Interaction, InteractionData, InteractionDataResolved, InteractionMember, InteractionType,
};
use crate::{
application::{
command::{CommandOptionType, CommandType},
monetization::{entitlement::Entitlement, EntitlementType},
},
channel::Channel,
guild::{MemberFlags, PartialMember, Permissions},
id::Id,
oauth::ApplicationIntegrationMap,
test::image_hash,
user::User,
util::datetime::{Timestamp, TimestampParseError},
};
use serde_test::Token;
use std::{collections::HashMap, str::FromStr};
#[test]
#[allow(clippy::too_many_lines, deprecated)]
fn test_interaction_full() -> Result<(), TimestampParseError> {
let joined_at = Some(Timestamp::from_str("2020-01-01T00:00:00.000000+00:00")?);
let flags = MemberFlags::BYPASSES_VERIFICATION | MemberFlags::DID_REJOIN;
let value = Interaction {
app_permissions: Some(Permissions::SEND_MESSAGES),
application_id: Id::new(100),
authorizing_integration_owners: ApplicationIntegrationMap {
guild: None,
user: None,
},
channel: Some(Channel {
bitrate: None,
guild_id: None,
id: Id::new(400),
kind: crate::channel::ChannelType::GuildText,
last_message_id: None,
last_pin_timestamp: None,
name: None,
nsfw: None,
owner_id: None,
parent_id: None,
permission_overwrites: None,
position: None,
rate_limit_per_user: None,
recipients: None,
rtc_region: None,
topic: None,
user_limit: None,
application_id: None,
applied_tags: None,
available_tags: None,
default_auto_archive_duration: None,
default_forum_layout: None,
default_reaction_emoji: None,
default_sort_order: None,
default_thread_rate_limit_per_user: None,
flags: None,
icon: None,
invitable: None,
managed: None,
member: None,
member_count: None,
message_count: None,
newly_created: None,
thread_metadata: None,
video_quality_mode: None,
}),
channel_id: Some(Id::new(200)),
context: None,
data: Some(InteractionData::ApplicationCommand(Box::new(CommandData {
guild_id: None,
id: Id::new(300),
name: "command name".into(),
kind: CommandType::ChatInput,
options: Vec::from([CommandDataOption {
name: "member".into(),
value: CommandOptionValue::User(Id::new(600)),
}]),
resolved: Some(InteractionDataResolved {
attachments: HashMap::new(),
channels: HashMap::new(),
members: IntoIterator::into_iter([(
Id::new(600),
InteractionMember {
avatar: None,
communication_disabled_until: None,
flags,
joined_at,
nick: Some("nickname".into()),
pending: false,
permissions: Permissions::empty(),
premium_since: None,
roles: Vec::new(),
},
)])
.collect(),
messages: HashMap::new(),
roles: HashMap::new(),
users: IntoIterator::into_iter([(
Id::new(600),
User {
accent_color: None,
avatar: Some(image_hash::AVATAR),
avatar_decoration: None,
avatar_decoration_data: None,
banner: None,
bot: false,
discriminator: 1111,
email: None,
flags: None,
global_name: Some("test".into()),
id: Id::new(600),
locale: None,
mfa_enabled: None,
name: "username".into(),
premium_type: None,
public_flags: None,
system: None,
verified: None,
},
)])
.collect(),
}),
target_id: None,
}))),
entitlements: vec![Entitlement {
application_id: Id::new(100),
consumed: Some(false),
deleted: false,
ends_at: None,
guild_id: None,
id: Id::new(200),
kind: EntitlementType::ApplicationSubscription,
sku_id: Id::new(300),
starts_at: None,
user_id: None,
}],
guild: None,
guild_id: Some(Id::new(400)),
guild_locale: Some("de".to_owned()),
id: Id::new(500),
kind: InteractionType::ApplicationCommand,
locale: Some("en-GB".to_owned()),
member: Some(PartialMember {
avatar: None,
communication_disabled_until: None,
deaf: false,
flags,
joined_at,
mute: false,
nick: Some("nickname".into()),
permissions: Some(Permissions::empty()),
premium_since: None,
roles: Vec::new(),
user: Some(User {
accent_color: None,
avatar: Some(image_hash::AVATAR),
avatar_decoration: None,
avatar_decoration_data: None,
banner: None,
bot: false,
discriminator: 1111,
email: None,
flags: None,
global_name: Some("test".into()),
id: Id::new(600),
locale: None,
mfa_enabled: None,
name: "username".into(),
premium_type: None,
public_flags: None,
system: None,
verified: None,
}),
}),
message: None,
token: "interaction token".into(),
user: None,
};
// TODO: switch the `assert_tokens` see #2190
serde_test::assert_ser_tokens(
&value,
&[
Token::Struct {
name: "Interaction",
len: 14,
},
Token::Str("app_permissions"),
Token::Some,
Token::Str("2048"),
Token::Str("application_id"),
Token::NewtypeStruct { name: "Id" },
Token::Str("100"),
Token::Str("authorizing_integration_owners"),
Token::Struct {
name: "ApplicationIntegrationMap",
len: 0,
},
Token::StructEnd,
Token::Str("channel"),
Token::Some,
Token::Struct {
name: "Channel",
len: 2,
},
Token::Str("id"),
Token::NewtypeStruct { name: "Id" },
Token::Str("400"),
Token::Str("type"),
Token::U8(0),
Token::StructEnd,
Token::Str("channel_id"),
Token::Some,
Token::NewtypeStruct { name: "Id" },
Token::Str("200"),
Token::Str("data"),
Token::Some,
Token::Struct {
name: "CommandData",
len: 5,
},
Token::Str("id"),
Token::NewtypeStruct { name: "Id" },
Token::Str("300"),
Token::Str("name"),
Token::Str("command name"),
Token::Str("type"),
Token::U8(1),
Token::Str("options"),
Token::Seq { len: Some(1) },
Token::Struct {
name: "CommandDataOption",
len: 3,
},
Token::Str("name"),
Token::Str("member"),
Token::Str("type"),
Token::U8(CommandOptionType::User as u8),
Token::Str("value"),
Token::NewtypeStruct { name: "Id" },
Token::Str("600"),
Token::StructEnd,
Token::SeqEnd,
Token::Str("resolved"),
Token::Some,
Token::Struct {
name: "InteractionDataResolved",
len: 2,
},
Token::Str("members"),
Token::Map { len: Some(1) },
Token::NewtypeStruct { name: "Id" },
Token::Str("600"),
Token::Struct {
name: "InteractionMember",
len: 7,
},
Token::Str("communication_disabled_until"),
Token::None,
Token::Str("flags"),
Token::U64(flags.bits()),
Token::Str("joined_at"),
Token::Some,
Token::Str("2020-01-01T00:00:00.000000+00:00"),
Token::Str("nick"),
Token::Some,
Token::Str("nickname"),
Token::Str("pending"),
Token::Bool(false),
Token::Str("permissions"),
Token::Str("0"),
Token::Str("roles"),
Token::Seq { len: Some(0) },
Token::SeqEnd,
Token::StructEnd,
Token::MapEnd,
Token::Str("users"),
Token::Map { len: Some(1) },
Token::NewtypeStruct { name: "Id" },
Token::Str("600"),
Token::Struct {
name: "User",
len: 10,
},
Token::Str("accent_color"),
Token::None,
Token::Str("avatar"),
Token::Some,
Token::Str(image_hash::AVATAR_INPUT),
Token::Str("avatar_decoration"),
Token::None,
Token::Str("avatar_decoration_data"),
Token::None,
Token::Str("banner"),
Token::None,
Token::Str("bot"),
Token::Bool(false),
Token::Str("discriminator"),
Token::Str("1111"),
Token::Str("global_name"),
Token::Some,
Token::Str("test"),
Token::Str("id"),
Token::NewtypeStruct { name: "Id" },
Token::Str("600"),
Token::Str("username"),
Token::Str("username"),
Token::StructEnd,
Token::MapEnd,
Token::StructEnd,
Token::StructEnd,
Token::Str("entitlements"),
Token::Seq { len: Some(1) },
Token::Struct {
name: "Entitlement",
len: 6,
},
Token::Str("application_id"),
Token::NewtypeStruct { name: "Id" },
Token::Str("100"),
Token::Str("consumed"),
Token::Some,
Token::Bool(false),
Token::Str("deleted"),
Token::Bool(false),
Token::Str("id"),
Token::NewtypeStruct { name: "Id" },
Token::Str("200"),
Token::Str("type"),
Token::U8(8),
Token::Str("sku_id"),
Token::NewtypeStruct { name: "Id" },
Token::Str("300"),
Token::StructEnd,
Token::SeqEnd,
Token::Str("guild_id"),
Token::Some,
Token::NewtypeStruct { name: "Id" },
Token::Str("400"),
Token::Str("guild_locale"),
Token::Some,
Token::String("de"),
Token::Str("id"),
Token::NewtypeStruct { name: "Id" },
Token::Str("500"),
Token::Str("type"),
Token::U8(InteractionType::ApplicationCommand as u8),
Token::Str("locale"),
Token::Some,
Token::Str("en-GB"),
Token::Str("member"),
Token::Some,
Token::Struct {
name: "PartialMember",
len: 9,
},
Token::Str("communication_disabled_until"),
Token::None,
Token::Str("deaf"),
Token::Bool(false),
Token::Str("flags"),
Token::U64(flags.bits()),
Token::Str("joined_at"),
Token::Some,
Token::Str("2020-01-01T00:00:00.000000+00:00"),
Token::Str("mute"),
Token::Bool(false),
Token::Str("nick"),
Token::Some,
Token::Str("nickname"),
Token::Str("permissions"),
Token::Some,
Token::Str("0"),
Token::Str("roles"),
Token::Seq { len: Some(0) },
Token::SeqEnd,
Token::Str("user"),
Token::Some,
Token::Struct {
name: "User",
len: 10,
},
Token::Str("accent_color"),
Token::None,
Token::Str("avatar"),
Token::Some,
Token::Str(image_hash::AVATAR_INPUT),
Token::Str("avatar_decoration"),
Token::None,
Token::Str("avatar_decoration_data"),
Token::None,
Token::Str("banner"),
Token::None,
Token::Str("bot"),
Token::Bool(false),
Token::Str("discriminator"),
Token::Str("1111"),
Token::Str("global_name"),
Token::Some,
Token::Str("test"),
Token::Str("id"),
Token::NewtypeStruct { name: "Id" },
Token::Str("600"),
Token::Str("username"),
Token::Str("username"),
Token::StructEnd,
Token::StructEnd,
Token::Str("token"),
Token::Str("interaction token"),
Token::StructEnd,
],
);
Ok(())
}
}