Fixed spell descriptions
This commit is contained in:
@@ -9,7 +9,7 @@ use crate::db::{schema::guilds, connection};
|
||||
pub struct QueryGuild {
|
||||
pub id: i64,
|
||||
pub bot_id: i64,
|
||||
pub volume: f64
|
||||
pub volume: i32
|
||||
}
|
||||
|
||||
impl QueryGuild {
|
||||
@@ -25,7 +25,7 @@ impl QueryGuild {
|
||||
pub struct InsertGuild {
|
||||
pub id: i64,
|
||||
pub bot_id: i64,
|
||||
pub volume: f64
|
||||
pub volume: i32
|
||||
}
|
||||
|
||||
impl InsertGuild {
|
||||
@@ -35,7 +35,7 @@ impl InsertGuild {
|
||||
Ok(guild)
|
||||
}
|
||||
|
||||
pub fn update_audio(id: i64, volume: f64) -> Result<QueryGuild, ServiceError> {
|
||||
pub fn update_audio(id: i64, volume: i32) -> Result<QueryGuild, ServiceError> {
|
||||
let mut conn = connection()?;
|
||||
let guild = diesel::update(guilds::table.filter(guilds::id.eq(id))).set(guilds::volume.eq(volume)).get_result(&mut conn)?;
|
||||
Ok(guild)
|
||||
|
||||
@@ -35,6 +35,6 @@ diesel::table! {
|
||||
guilds (id) {
|
||||
id -> BigInt,
|
||||
bot_id -> BigInt,
|
||||
volume -> Float8,
|
||||
volume -> Integer,
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ use crate::db::{schema::spells::{self}, classes::AbilityType, conditions::Condit
|
||||
|
||||
use super::{SchoolType, CastingTime, SpellAttackType, SpellDamageType, Range, Area, Components, Duration, Source, Description, DurationType, Effect};
|
||||
|
||||
#[derive(Queryable, QueryableByName, Serialize, Deserialize)]
|
||||
#[derive(Debug, Queryable, QueryableByName, Serialize, Deserialize)]
|
||||
#[diesel(table_name = spells)]
|
||||
pub struct QuerySpell {
|
||||
pub id: i32,
|
||||
@@ -163,7 +163,7 @@ impl QuerySpell {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Insertable, AsChangeset)]
|
||||
#[derive(Debug, Insertable, AsChangeset)]
|
||||
#[diesel(table_name = spells)]
|
||||
pub struct InsertSpell {
|
||||
pub name: String,
|
||||
|
||||
@@ -263,7 +263,7 @@ pub struct Description {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Entry {
|
||||
pub text: Option<Vec<String>>,
|
||||
pub text: Option<String>,
|
||||
pub list: Option<Vec<String>>,
|
||||
pub table: Option<EntryTable>
|
||||
}
|
||||
@@ -279,11 +279,18 @@ impl<'de> Deserialize<'de> for Entry {
|
||||
let value = serde_json::Value::deserialize(deserializer)?;
|
||||
match value {
|
||||
serde_json::Value::String(s) => Ok(Entry {
|
||||
text: Some(vec![s]),
|
||||
text: Some(s),
|
||||
list: None,
|
||||
table: None,
|
||||
}),
|
||||
serde_json::Value::Object(o) => {
|
||||
let text = match o.get("text") {
|
||||
Some(t) => match t.as_str() {
|
||||
Some(s) => Some(s.to_string()),
|
||||
None => return Err(serde::de::Error::custom("Invalid entry text"))
|
||||
},
|
||||
None => None
|
||||
};
|
||||
let list = match o.get("list") {
|
||||
Some(i) => match i.as_array() {
|
||||
Some(a) => {
|
||||
@@ -352,7 +359,7 @@ impl<'de> Deserialize<'de> for Entry {
|
||||
None => None
|
||||
};
|
||||
Ok(Entry {
|
||||
text: None,
|
||||
text,
|
||||
list,
|
||||
table
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user