Merge branch 'refactor/application-default'
This commit is contained in:
commit
0504f0a9d2
|
@ -3,9 +3,6 @@ use crate::types::{Team, User};
|
||||||
use bitflags::{bitflags, Flags};
|
use bitflags::{bitflags, Flags};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use serde_repr::{Serialize_repr, Deserialize_repr};
|
|
||||||
#[cfg(feature = "sqlx")]
|
|
||||||
use sqlx::FromRow;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
|
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
|
||||||
|
@ -53,6 +50,40 @@ pub struct Application {
|
||||||
pub team: Option<Team>,
|
pub team: Option<Team>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Application {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
id: Default::default(),
|
||||||
|
name: "".to_string(),
|
||||||
|
icon: None,
|
||||||
|
description: None,
|
||||||
|
summary: None,
|
||||||
|
r#type: None,
|
||||||
|
hook: true,
|
||||||
|
bot_public: true,
|
||||||
|
bot_require_code_grant: false,
|
||||||
|
verify_key: "".to_string(),
|
||||||
|
owner: Default::default(),
|
||||||
|
flags: 0,
|
||||||
|
redirect_uris: None,
|
||||||
|
rpc_application_state: 0,
|
||||||
|
store_application_state: 1,
|
||||||
|
verification_state: 1,
|
||||||
|
interactions_endpoint_url: None,
|
||||||
|
integration_public: true,
|
||||||
|
integration_require_code_grant: false,
|
||||||
|
discoverability_state: 1,
|
||||||
|
discovery_eligibility_flags: 2240,
|
||||||
|
tags: None,
|
||||||
|
cover_image: None,
|
||||||
|
install_params: None,
|
||||||
|
terms_of_service_url: None,
|
||||||
|
privacy_policy_url: None,
|
||||||
|
team: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Application {
|
impl Application {
|
||||||
pub fn flags(&self) -> ApplicationFlags {
|
pub fn flags(&self) -> ApplicationFlags {
|
||||||
ApplicationFlags::from_bits(self.flags.to_owned()).unwrap()
|
ApplicationFlags::from_bits(self.flags.to_owned()).unwrap()
|
||||||
|
@ -106,23 +137,17 @@ pub struct ApplicationCommandOptionChoice {
|
||||||
pub value: Value,
|
pub value: Value,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Copy, PartialEq, Serialize_repr, Deserialize_repr)]
|
||||||
|
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
|
||||||
|
#[repr(i32)]
|
||||||
pub enum ApplicationCommandOptionType {
|
pub enum ApplicationCommandOptionType {
|
||||||
#[serde(rename = "SUB_COMMAND")]
|
|
||||||
SubCommand = 1,
|
SubCommand = 1,
|
||||||
#[serde(rename = "SUB_COMMAND_GROUP")]
|
|
||||||
SubCommandGroup = 2,
|
SubCommandGroup = 2,
|
||||||
#[serde(rename = "STRING")]
|
|
||||||
String = 3,
|
String = 3,
|
||||||
#[serde(rename = "INTEGER")]
|
|
||||||
Integer = 4,
|
Integer = 4,
|
||||||
#[serde(rename = "BOOLEAN")]
|
|
||||||
Boolean = 5,
|
Boolean = 5,
|
||||||
#[serde(rename = "USER")]
|
|
||||||
User = 6,
|
User = 6,
|
||||||
#[serde(rename = "CHANNEL")]
|
|
||||||
Channel = 7,
|
Channel = 7,
|
||||||
#[serde(rename = "ROLE")]
|
|
||||||
Role = 8,
|
Role = 8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,12 +185,12 @@ pub struct ApplicationCommandPermission {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize_repr, Deserialize_repr, Debug, Default, Clone, PartialEq)]
|
#[derive(Serialize_repr, Deserialize_repr, Debug, Default, Clone, PartialEq)]
|
||||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
/// See https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permission-type
|
/// See https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permission-type
|
||||||
pub enum ApplicationCommandPermissionType {
|
pub enum ApplicationCommandPermissionType {
|
||||||
#[default]
|
#[default]
|
||||||
Role = 1,
|
Role = 1,
|
||||||
User = 2,
|
User = 2,
|
||||||
Channel = 3
|
Channel = 3,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue