Update to serenity 12
This commit is contained in:
1 parent
cd5651c7f6
commit
e632f55b4e
14 files changed
+1669
-1116
No files matched your search
@@ -78,12 +78,10 @@ impl GuildData {
|
||||
|
||||
let guild_data = sqlx::query_as_unchecked!(
|
||||
GuildData,
|
||||
"
|
||||
SELECT id, prefix, volume, allow_greets, allowed_role
|
||||
FROM servers
|
||||
WHERE id = ?
|
||||
",
|
||||
guild_id.as_u64()
|
||||
"SELECT id, prefix, volume, allow_greets, allowed_role
|
||||
FROM servers
|
||||
WHERE id = ?",
|
||||
guild_id.get()
|
||||
)
|
||||
.fetch_one(db_pool)
|
||||
.await;
|
||||
@@ -104,17 +102,15 @@ SELECT id, prefix, volume, allow_greets, allowed_role
|
||||
let guild_id = guild_id.into();
|
||||
|
||||
sqlx::query!(
|
||||
"
|
||||
INSERT INTO servers (id)
|
||||
VALUES (?)
|
||||
",
|
||||
guild_id.as_u64()
|
||||
"INSERT INTO servers (id)
|
||||
VALUES (?)",
|
||||
guild_id.get()
|
||||
)
|
||||
.execute(db_pool)
|
||||
.await?;
|
||||
|
||||
Ok(GuildData {
|
||||
id: guild_id.as_u64().to_owned(),
|
||||
id: guild_id.get(),
|
||||
prefix: String::from("?"),
|
||||
volume: 100,
|
||||
allow_greets: AllowGreet::Enabled,
|
||||
|
||||
+20
-22
@@ -47,14 +47,13 @@ impl JoinSoundCtx for Data {
|
||||
sqlx::query_as!(
|
||||
JoinSound,
|
||||
"
|
||||
SELECT join_sound_id
|
||||
FROM join_sounds
|
||||
WHERE user = ?
|
||||
AND guild = ?
|
||||
ORDER BY guild IS NULL
|
||||
",
|
||||
user_id.as_u64(),
|
||||
guild_id.map(|g| g.0)
|
||||
SELECT join_sound_id
|
||||
FROM join_sounds
|
||||
WHERE user = ?
|
||||
AND guild = ?
|
||||
ORDER BY guild IS NULL",
|
||||
user_id.get(),
|
||||
guild_id.map(|g| g.get())
|
||||
)
|
||||
.fetch_one(&self.database)
|
||||
.await
|
||||
@@ -62,14 +61,13 @@ SELECT join_sound_id
|
||||
sqlx::query_as!(
|
||||
JoinSound,
|
||||
"
|
||||
SELECT join_sound_id
|
||||
FROM join_sounds
|
||||
WHERE user = ?
|
||||
AND (guild IS NULL OR guild = ?)
|
||||
ORDER BY guild IS NULL
|
||||
",
|
||||
user_id.as_u64(),
|
||||
guild_id.map(|g| g.0)
|
||||
SELECT join_sound_id
|
||||
FROM join_sounds
|
||||
WHERE user = ?
|
||||
AND (guild IS NULL OR guild = ?)
|
||||
ORDER BY guild IS NULL",
|
||||
user_id.get(),
|
||||
guild_id.map(|g| g.get())
|
||||
)
|
||||
.fetch_one(&self.database)
|
||||
.await
|
||||
@@ -111,17 +109,17 @@ SELECT join_sound_id
|
||||
Some(join_id) => {
|
||||
sqlx::query!(
|
||||
"DELETE FROM join_sounds WHERE user = ? AND guild <=> ?",
|
||||
user_id.0,
|
||||
guild_id.map(|g| g.0)
|
||||
user_id.get(),
|
||||
guild_id.map(|g| g.get())
|
||||
)
|
||||
.execute(&mut transaction)
|
||||
.await?;
|
||||
|
||||
sqlx::query!(
|
||||
"INSERT INTO join_sounds (user, join_sound_id, guild) VALUES (?, ?, ?)",
|
||||
user_id.0,
|
||||
user_id.get(),
|
||||
join_id,
|
||||
guild_id.map(|g| g.0)
|
||||
guild_id.map(|g| g.get())
|
||||
)
|
||||
.execute(&mut transaction)
|
||||
.await?;
|
||||
@@ -130,8 +128,8 @@ SELECT join_sound_id
|
||||
None => {
|
||||
sqlx::query!(
|
||||
"DELETE FROM join_sounds WHERE user = ? AND guild <=> ?",
|
||||
user_id.0,
|
||||
guild_id.map(|g| g.0)
|
||||
user_id.get(),
|
||||
guild_id.map(|g| g.get())
|
||||
)
|
||||
.execute(&mut transaction)
|
||||
.await?;
|
||||
|
||||
+4
-6
@@ -1,7 +1,7 @@
|
||||
use std::{env, path::Path};
|
||||
|
||||
use poise::serenity_prelude::async_trait;
|
||||
use songbird::input::restartable::Restartable;
|
||||
use songbird::input::Input;
|
||||
use sqlx::Executor;
|
||||
use tokio::{fs::File, io::AsyncWriteExt, process::Command};
|
||||
|
||||
@@ -426,7 +426,7 @@ impl Sound {
|
||||
) -> Result<String, Box<dyn std::error::Error + Send + Sync>> {
|
||||
let caching_location = env::var("CACHING_LOCATION").unwrap_or(String::from("/tmp"));
|
||||
|
||||
let path_name = format!("{}/sound-{}", caching_location, self.id);
|
||||
let path_name = format!("{}/sound-{}.opus", caching_location, self.id);
|
||||
let path = Path::new(&path_name);
|
||||
|
||||
if !path.exists() {
|
||||
@@ -441,12 +441,10 @@ impl Sound {
|
||||
pub async fn playable(
|
||||
&self,
|
||||
db_pool: impl Executor<'_, Database = Database>,
|
||||
) -> Result<Restartable, Box<dyn std::error::Error + Send + Sync>> {
|
||||
) -> Result<Input, Box<dyn std::error::Error + Send + Sync>> {
|
||||
let path_name = self.store_sound_source(db_pool).await?;
|
||||
|
||||
Ok(Restartable::ffmpeg(path_name, false)
|
||||
.await
|
||||
.expect("FFMPEG ERROR!"))
|
||||
Ok(Input::from(path_name))
|
||||
}
|
||||
|
||||
pub async fn count_user_sounds<U: Into<u64>>(
|
||||
|
||||
Reference in new issue
Block a user