#![allow(non_snake_case)]
use crate::models::payloads::_interactions::_application_commands::context_menu;
use crate::models::payloads::APIMessageComponentInteractionData;
use crate::models::payloads::{
APIApplicationCommandInteraction, APIButtonComponent, APIInteraction,
APIMessageComponentInteraction,
};
pub fn isDMInteraction(interaction: &APIInteraction) -> bool {
match interaction {
APIInteraction::APIApplicationCommandAutocompleteInteraction(x) => x.guild_id.is_none(),
APIInteraction::APIApplicationCommandInteraction(i) => match i {
APIApplicationCommandInteraction::APIChatInputApplicationCommandInteraction(x) => {
x.guild_id.is_none()
}
APIApplicationCommandInteraction::APIContextMenuInteraction(ctx) => match ctx {
context_menu::APIContextMenuInteraction::APIUserApplicationCommandInteraction(x) => {
x.guild_id.is_none()
}
context_menu::APIContextMenuInteraction::APIMessageApplicationCommandInteraction(
x,
) => x.guild_id.is_none(),
},
APIApplicationCommandInteraction::APIPrimaryEntryPointCommandInteraction(x) => {
x.guild_id.is_none()
}
},
APIInteraction::APIMessageComponentInteraction(x) => x.guild_id.is_none(),
APIInteraction::APIModalSubmitInteraction(x) => x.guild_id.is_none(),
APIInteraction::APIPingInteraction(x) => x.guild_id.is_none(),
}
}
pub fn isGuildInteraction(interaction: &APIInteraction) -> bool {
!isDMInteraction(interaction)
}
pub fn isApplicationCommandDMInteraction(interaction: &APIApplicationCommandInteraction) -> bool {
match interaction {
APIApplicationCommandInteraction::APIChatInputApplicationCommandInteraction(x) => {
x.guild_id.is_none()
}
APIApplicationCommandInteraction::APIContextMenuInteraction(ctx) => match ctx {
context_menu::APIContextMenuInteraction::APIUserApplicationCommandInteraction(x) => {
x.guild_id.is_none()
}
context_menu::APIContextMenuInteraction::APIMessageApplicationCommandInteraction(x) => {
x.guild_id.is_none()
}
},
APIApplicationCommandInteraction::APIPrimaryEntryPointCommandInteraction(x) => {
x.guild_id.is_none()
}
}
}
pub fn isApplicationCommandGuildInteraction(
interaction: &APIApplicationCommandInteraction,
) -> bool {
!isApplicationCommandDMInteraction(interaction)
}
pub fn isMessageComponentDMInteraction(interaction: &APIMessageComponentInteraction) -> bool {
interaction.guild_id.is_none()
}
pub fn isMessageComponentGuildInteraction(interaction: &APIMessageComponentInteraction) -> bool {
interaction.guild_id.is_some()
}
pub fn isLinkButton(component: &APIButtonComponent) -> bool {
matches!(component, APIButtonComponent::APIButtonComponentWithURL(_))
}
pub fn isInteractionButton(component: &APIButtonComponent) -> bool {
matches!(
component,
APIButtonComponent::APIButtonComponentWithCustomId(_)
| APIButtonComponent::APIButtonComponentWithSKUId(_)
)
}
pub fn isMessageComponentInteraction(interaction: &APIInteraction) -> bool {
matches!(
interaction,
APIInteraction::APIMessageComponentInteraction(_)
)
}
pub fn isMessageComponentButtonInteraction(interaction: &APIMessageComponentInteraction) -> bool {
matches!(
interaction.data.as_ref(),
Some(APIMessageComponentInteractionData::APIMessageButtonInteractionData(_))
)
}
pub fn isMessageComponentSelectMenuInteraction(
interaction: &APIMessageComponentInteraction,
) -> bool {
matches!(
interaction.data.as_ref(),
Some(APIMessageComponentInteractionData::APIMessageSelectMenuInteractionData(_))
)
}
pub fn isChatInputApplicationCommandInteraction(
interaction: &APIApplicationCommandInteraction,
) -> bool {
matches!(
interaction,
APIApplicationCommandInteraction::APIChatInputApplicationCommandInteraction(_)
)
}
pub fn isContextMenuApplicationCommandInteraction(
interaction: &APIApplicationCommandInteraction,
) -> bool {
matches!(
interaction,
APIApplicationCommandInteraction::APIContextMenuInteraction(_)
)
}