|
- use serde::{Deserialize, Serialize};
-
- #[derive(Serialize, Deserialize, Clone)]
- #[serde(tag = "type")]
- pub enum Interaction {
- #[serde(rename = "1")]
- Ping {},
- #[serde(rename = "2")]
- Command {
- token: String,
- // member: Member,
- id: String,
- guild_id: String,
- // data: Command,
- channel_id: String,
- //version: usize,
- },
- }
-
- impl Interaction {
- pub fn is_ping(&self) -> bool {
- match self {
- Self::Ping {..} => true,
- Self::Command {..} => false,
- }
- }
- }
-
- #[derive(Serialize, Deserialize, Clone)]
- #[serde(tag = "type")]
- pub enum InteractionResponse {
- #[serde(rename = "1")]
- Pong {},
- #[serde(rename = "2")]
- Acknowledge {},
- #[serde(rename = "3")]
- ChannelMessage {
- data: Option<InteractionApplicationCommandCallbackData>,
- },
- #[serde(rename = "4")]
- ChannelMessageWithSource {
- data: Option<InteractionApplicationCommandCallbackData>,
- },
- #[serde(rename = "5")]
- AcknowledgeWithSource {},
- }
-
- #[derive(Serialize, Deserialize, Clone)]
- pub struct InteractionApplicationCommandCallbackData {
- pub tts: bool,
- pub content: String,
- //pub embeds: Option<Vec<Embed>>,
- pub allowed_mentions: Option<String>,
- }
-
- // slash command management structures
- #[derive(Serialize, Deserialize, Clone)]
- pub struct ApplicationCommand {
- pub id: Option<String>,
- pub application_id: Option<String>,
- pub name: String,
- pub description: String,
- pub options: Option<Vec<ApplicationCommandOption>>,
- }
-
- #[derive(Serialize, Deserialize, Clone)]
- #[serde(tag = "type")]
- pub enum ApplicationCommandOption {
- #[serde(rename = "1")]
- SubCommand {
- name: String,
- description: String,
- required: bool,
- options: Option<Vec<ApplicationCommandOption>>,
- },
- #[serde(rename = "2")]
- SubCommandGroup {
- name: String,
- description: String,
- required: bool,
- options: Option<Vec<ApplicationCommandOption>>,
- },
- #[serde(rename = "3")]
- String {
- name: String,
- description: String,
- required: bool,
- choices: Option<Vec<ApplicationCommandOptionChoice>>,
- },
- #[serde(rename = "4")]
- Integer {
- name: String,
- description: String,
- required: bool,
- choices: Option<Vec<ApplicationCommandOptionChoice>>,
- },
- #[serde(rename = "5")]
- Boolean {
- name: String,
- description: String,
- required: bool,
- },
- #[serde(rename = "6")]
- User {
- name: String,
- description: String,
- required: bool,
- },
- #[serde(rename = "7")]
- Channel {
- name: String,
- description: String,
- required: bool,
- },
- #[serde(rename = "8")]
- Role {
- name: String,
- description: String,
- required: bool,
- },
- }
-
- #[derive(Serialize, Deserialize, Clone)]
- pub struct ApplicationCommandOptionChoice {
- pub name: String,
- pub value: String,
- }
|