renamed a function. removed name from guild
This commit is contained in:
parent
619678de36
commit
d57e1d3ab1
446
Cargo.lock
generated
446
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,6 @@ use sqlx::mysql::MySqlPool;
|
|||||||
|
|
||||||
pub struct GuildData {
|
pub struct GuildData {
|
||||||
pub id: u64,
|
pub id: u64,
|
||||||
pub name: Option<String>,
|
|
||||||
pub prefix: String,
|
pub prefix: String,
|
||||||
pub volume: u8,
|
pub volume: u8,
|
||||||
pub allow_greets: bool,
|
pub allow_greets: bool,
|
||||||
@ -14,7 +13,7 @@ impl GuildData {
|
|||||||
let guild_data = sqlx::query_as_unchecked!(
|
let guild_data = sqlx::query_as_unchecked!(
|
||||||
GuildData,
|
GuildData,
|
||||||
"
|
"
|
||||||
SELECT id, name, prefix, volume, allow_greets
|
SELECT id, prefix, volume, allow_greets
|
||||||
FROM servers
|
FROM servers
|
||||||
WHERE id = ?
|
WHERE id = ?
|
||||||
",
|
",
|
||||||
@ -64,7 +63,6 @@ INSERT IGNORE INTO roles (guild_id, role)
|
|||||||
|
|
||||||
Ok(GuildData {
|
Ok(GuildData {
|
||||||
id: *guild.id.as_u64(),
|
id: *guild.id.as_u64(),
|
||||||
name: Some(guild.name.clone()),
|
|
||||||
prefix: String::from("?"),
|
prefix: String::from("?"),
|
||||||
volume: 100,
|
volume: 100,
|
||||||
allow_greets: true,
|
allow_greets: true,
|
||||||
@ -79,14 +77,12 @@ INSERT IGNORE INTO roles (guild_id, role)
|
|||||||
"
|
"
|
||||||
UPDATE servers
|
UPDATE servers
|
||||||
SET
|
SET
|
||||||
name = ?,
|
|
||||||
prefix = ?,
|
prefix = ?,
|
||||||
volume = ?,
|
volume = ?,
|
||||||
allow_greets = ?
|
allow_greets = ?
|
||||||
WHERE
|
WHERE
|
||||||
id = ?
|
id = ?
|
||||||
",
|
",
|
||||||
self.name,
|
|
||||||
self.prefix,
|
self.prefix,
|
||||||
self.volume,
|
self.volume,
|
||||||
self.allow_greets,
|
self.allow_greets,
|
||||||
|
10
src/main.rs
10
src/main.rs
@ -457,15 +457,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
match GuildData::get_from_id(guild.clone(), pool.clone()).await {
|
match GuildData::get_from_id(guild.clone(), pool.clone()).await {
|
||||||
Some(mut guild_data) => {
|
Some(guild_data) => Some(guild_data.prefix),
|
||||||
let name = Some(guild.name);
|
|
||||||
|
|
||||||
if guild_data.name != name {
|
|
||||||
guild_data.name = name;
|
|
||||||
guild_data.commit(pool).await.unwrap();
|
|
||||||
}
|
|
||||||
Some(guild_data.prefix)
|
|
||||||
}
|
|
||||||
|
|
||||||
None => {
|
None => {
|
||||||
GuildData::create_from_guild(guild, pool).await.unwrap();
|
GuildData::create_from_guild(guild, pool).await.unwrap();
|
||||||
|
@ -111,7 +111,7 @@ SELECT name, id, plays, public, server_id, uploader_id
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_self_src(&self, db_pool: MySqlPool) -> Vec<u8> {
|
async fn src(&self, db_pool: MySqlPool) -> Vec<u8> {
|
||||||
struct Src {
|
struct Src {
|
||||||
src: Vec<u8>,
|
src: Vec<u8>,
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ SELECT src
|
|||||||
if !path.exists() {
|
if !path.exists() {
|
||||||
let mut file = File::create(&path).await?;
|
let mut file = File::create(&path).await?;
|
||||||
|
|
||||||
file.write_all(&self.get_self_src(db_pool).await).await?;
|
file.write_all(&self.src(db_pool).await).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(ffmpeg(path_name).await.expect("FFMPEG ERROR!"))
|
Ok(ffmpeg(path_name).await.expect("FFMPEG ERROR!"))
|
||||||
|
Loading…
Reference in New Issue
Block a user