Remove broken is_text_based check
This commit is contained in:
parent
8390bf0ec6
commit
6d324e10cb
@ -25,10 +25,6 @@ pub async fn play(
|
|||||||
|
|
||||||
let guild = ctx.guild().unwrap();
|
let guild = ctx.guild().unwrap();
|
||||||
|
|
||||||
if channel.as_ref().map_or(false, |c| c.is_text_based()) {
|
|
||||||
ctx.say("The channel specified is not a voice channel.")
|
|
||||||
.await?;
|
|
||||||
} else {
|
|
||||||
ctx.say(
|
ctx.say(
|
||||||
play_from_query(
|
play_from_query(
|
||||||
&ctx.serenity_context(),
|
&ctx.serenity_context(),
|
||||||
@ -42,7 +38,6 @@ pub async fn play(
|
|||||||
.await,
|
.await,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -99,14 +99,13 @@ impl SoundCtx for Data {
|
|||||||
let sound = sqlx::query_as_unchecked!(
|
let sound = sqlx::query_as_unchecked!(
|
||||||
Sound,
|
Sound,
|
||||||
"
|
"
|
||||||
SELECT name, id, public, server_id, uploader_id
|
SELECT name, id, public, server_id, uploader_id
|
||||||
FROM sounds
|
FROM sounds
|
||||||
WHERE id = ? AND (
|
WHERE id = ? AND (
|
||||||
public = 1 OR
|
public = 1 OR
|
||||||
uploader_id = ? OR
|
uploader_id = ? OR
|
||||||
server_id = ?
|
server_id = ?
|
||||||
)
|
)",
|
||||||
",
|
|
||||||
id,
|
id,
|
||||||
user_id,
|
user_id,
|
||||||
guild_id
|
guild_id
|
||||||
@ -123,7 +122,7 @@ SELECT name, id, public, server_id, uploader_id
|
|||||||
sound = sqlx::query_as_unchecked!(
|
sound = sqlx::query_as_unchecked!(
|
||||||
Sound,
|
Sound,
|
||||||
"
|
"
|
||||||
SELECT name, id, public, server_id, uploader_id
|
SELECT name, id, public, server_id, uploader_id
|
||||||
FROM sounds
|
FROM sounds
|
||||||
WHERE name = ? AND (
|
WHERE name = ? AND (
|
||||||
public = 1 OR
|
public = 1 OR
|
||||||
@ -139,8 +138,7 @@ SELECT name, id, public, server_id, uploader_id
|
|||||||
) DESC,
|
) DESC,
|
||||||
server_id = ? DESC,
|
server_id = ? DESC,
|
||||||
public = 1 DESC,
|
public = 1 DESC,
|
||||||
rand()
|
rand()",
|
||||||
",
|
|
||||||
name,
|
name,
|
||||||
user_id,
|
user_id,
|
||||||
guild_id,
|
guild_id,
|
||||||
@ -154,7 +152,7 @@ SELECT name, id, public, server_id, uploader_id
|
|||||||
sound = sqlx::query_as_unchecked!(
|
sound = sqlx::query_as_unchecked!(
|
||||||
Sound,
|
Sound,
|
||||||
"
|
"
|
||||||
SELECT name, id, public, server_id, uploader_id
|
SELECT name, id, public, server_id, uploader_id
|
||||||
FROM sounds
|
FROM sounds
|
||||||
WHERE name LIKE CONCAT('%', ?, '%') AND (
|
WHERE name LIKE CONCAT('%', ?, '%') AND (
|
||||||
public = 1 OR
|
public = 1 OR
|
||||||
@ -170,8 +168,7 @@ SELECT name, id, public, server_id, uploader_id
|
|||||||
) DESC,
|
) DESC,
|
||||||
server_id = ? DESC,
|
server_id = ? DESC,
|
||||||
public = 1 DESC,
|
public = 1 DESC,
|
||||||
rand()
|
rand()",
|
||||||
",
|
|
||||||
name,
|
name,
|
||||||
user_id,
|
user_id,
|
||||||
guild_id,
|
guild_id,
|
||||||
@ -199,15 +196,14 @@ SELECT name, id, public, server_id, uploader_id
|
|||||||
sqlx::query_as_unchecked!(
|
sqlx::query_as_unchecked!(
|
||||||
Sound,
|
Sound,
|
||||||
"
|
"
|
||||||
SELECT name, id, public, server_id, uploader_id
|
SELECT name, id, public, server_id, uploader_id
|
||||||
FROM sounds
|
FROM sounds
|
||||||
WHERE name LIKE CONCAT(?, '%') AND (uploader_id = ? OR server_id = ? OR EXISTS(
|
WHERE name LIKE CONCAT(?, '%') AND (uploader_id = ? OR server_id = ? OR EXISTS(
|
||||||
SELECT 1
|
SELECT 1
|
||||||
FROM favorite_sounds
|
FROM favorite_sounds
|
||||||
WHERE sound_id = id AND user_id = ?
|
WHERE sound_id = id AND user_id = ?
|
||||||
))
|
))
|
||||||
LIMIT 25
|
LIMIT 25",
|
||||||
",
|
|
||||||
query,
|
query,
|
||||||
user_id,
|
user_id,
|
||||||
guild_id.into(),
|
guild_id.into(),
|
||||||
@ -227,15 +223,14 @@ LIMIT 25
|
|||||||
sqlx::query_as_unchecked!(
|
sqlx::query_as_unchecked!(
|
||||||
Sound,
|
Sound,
|
||||||
"
|
"
|
||||||
SELECT name, id, public, server_id, uploader_id
|
SELECT name, id, public, server_id, uploader_id
|
||||||
FROM sounds
|
FROM sounds
|
||||||
WHERE name LIKE CONCAT(?, '%') AND EXISTS(
|
WHERE name LIKE CONCAT(?, '%') AND EXISTS(
|
||||||
SELECT 1
|
SELECT 1
|
||||||
FROM favorite_sounds
|
FROM favorite_sounds
|
||||||
WHERE sound_id = id AND user_id = ?
|
WHERE sound_id = id AND user_id = ?
|
||||||
)
|
)
|
||||||
LIMIT 25
|
LIMIT 25",
|
||||||
",
|
|
||||||
query,
|
query,
|
||||||
user_id.into(),
|
user_id.into(),
|
||||||
)
|
)
|
||||||
@ -253,12 +248,11 @@ LIMIT 25
|
|||||||
sqlx::query_as_unchecked!(
|
sqlx::query_as_unchecked!(
|
||||||
Sound,
|
Sound,
|
||||||
"
|
"
|
||||||
SELECT name, id, public, server_id, uploader_id
|
SELECT name, id, public, server_id, uploader_id
|
||||||
FROM sounds
|
FROM sounds
|
||||||
WHERE uploader_id = ?
|
WHERE uploader_id = ?
|
||||||
ORDER BY id DESC
|
ORDER BY id DESC
|
||||||
LIMIT ?, ?
|
LIMIT ?, ?",
|
||||||
",
|
|
||||||
user_id.into(),
|
user_id.into(),
|
||||||
page * 25,
|
page * 25,
|
||||||
(page + 1) * 25
|
(page + 1) * 25
|
||||||
@ -270,11 +264,10 @@ SELECT name, id, public, server_id, uploader_id
|
|||||||
sqlx::query_as_unchecked!(
|
sqlx::query_as_unchecked!(
|
||||||
Sound,
|
Sound,
|
||||||
"
|
"
|
||||||
SELECT name, id, public, server_id, uploader_id
|
SELECT name, id, public, server_id, uploader_id
|
||||||
FROM sounds
|
FROM sounds
|
||||||
WHERE uploader_id = ?
|
WHERE uploader_id = ?
|
||||||
ORDER BY id DESC
|
ORDER BY id DESC",
|
||||||
",
|
|
||||||
user_id.into()
|
user_id.into()
|
||||||
)
|
)
|
||||||
.fetch_all(&self.database)
|
.fetch_all(&self.database)
|
||||||
@ -295,13 +288,12 @@ SELECT name, id, public, server_id, uploader_id
|
|||||||
sqlx::query_as_unchecked!(
|
sqlx::query_as_unchecked!(
|
||||||
Sound,
|
Sound,
|
||||||
"
|
"
|
||||||
SELECT name, id, public, server_id, uploader_id
|
SELECT name, id, public, server_id, uploader_id
|
||||||
FROM sounds
|
FROM sounds
|
||||||
INNER JOIN favorite_sounds f ON sounds.id = f.sound_id
|
INNER JOIN favorite_sounds f ON sounds.id = f.sound_id
|
||||||
WHERE f.user_id = ?
|
WHERE f.user_id = ?
|
||||||
ORDER BY id DESC
|
ORDER BY id DESC
|
||||||
LIMIT ?, ?
|
LIMIT ?, ?",
|
||||||
",
|
|
||||||
user_id.into(),
|
user_id.into(),
|
||||||
page * 25,
|
page * 25,
|
||||||
(page + 1) * 25
|
(page + 1) * 25
|
||||||
@ -313,12 +305,11 @@ SELECT name, id, public, server_id, uploader_id
|
|||||||
sqlx::query_as_unchecked!(
|
sqlx::query_as_unchecked!(
|
||||||
Sound,
|
Sound,
|
||||||
"
|
"
|
||||||
SELECT name, id, public, server_id, uploader_id
|
SELECT name, id, public, server_id, uploader_id
|
||||||
FROM sounds
|
FROM sounds
|
||||||
INNER JOIN favorite_sounds f ON sounds.id = f.sound_id
|
INNER JOIN favorite_sounds f ON sounds.id = f.sound_id
|
||||||
WHERE f.user_id = ?
|
WHERE f.user_id = ?
|
||||||
ORDER BY id DESC
|
ORDER BY id DESC",
|
||||||
",
|
|
||||||
user_id.into()
|
user_id.into()
|
||||||
)
|
)
|
||||||
.fetch_all(&self.database)
|
.fetch_all(&self.database)
|
||||||
@ -339,12 +330,11 @@ SELECT name, id, public, server_id, uploader_id
|
|||||||
sqlx::query_as_unchecked!(
|
sqlx::query_as_unchecked!(
|
||||||
Sound,
|
Sound,
|
||||||
"
|
"
|
||||||
SELECT name, id, public, server_id, uploader_id
|
SELECT name, id, public, server_id, uploader_id
|
||||||
FROM sounds
|
FROM sounds
|
||||||
WHERE server_id = ?
|
WHERE server_id = ?
|
||||||
ORDER BY id DESC
|
ORDER BY id DESC
|
||||||
LIMIT ?, ?
|
LIMIT ?, ?",
|
||||||
",
|
|
||||||
guild_id.into(),
|
guild_id.into(),
|
||||||
page * 25,
|
page * 25,
|
||||||
(page + 1) * 25
|
(page + 1) * 25
|
||||||
@ -357,11 +347,10 @@ SELECT name, id, public, server_id, uploader_id
|
|||||||
sqlx::query_as_unchecked!(
|
sqlx::query_as_unchecked!(
|
||||||
Sound,
|
Sound,
|
||||||
"
|
"
|
||||||
SELECT name, id, public, server_id, uploader_id
|
SELECT name, id, public, server_id, uploader_id
|
||||||
FROM sounds
|
FROM sounds
|
||||||
WHERE server_id = ?
|
WHERE server_id = ?
|
||||||
ORDER BY id DESC
|
ORDER BY id DESC",
|
||||||
",
|
|
||||||
guild_id.into()
|
guild_id.into()
|
||||||
)
|
)
|
||||||
.fetch_all(&self.database)
|
.fetch_all(&self.database)
|
||||||
@ -418,11 +407,10 @@ impl Sound {
|
|||||||
let record = sqlx::query_as_unchecked!(
|
let record = sqlx::query_as_unchecked!(
|
||||||
Src,
|
Src,
|
||||||
"
|
"
|
||||||
SELECT src
|
SELECT src
|
||||||
FROM sounds
|
FROM sounds
|
||||||
WHERE id = ?
|
WHERE id = ?
|
||||||
LIMIT 1
|
LIMIT 1",
|
||||||
",
|
|
||||||
self.id
|
self.id
|
||||||
)
|
)
|
||||||
.fetch_one(db_pool)
|
.fetch_one(db_pool)
|
||||||
@ -469,10 +457,9 @@ SELECT src
|
|||||||
|
|
||||||
let c = sqlx::query!(
|
let c = sqlx::query!(
|
||||||
"
|
"
|
||||||
SELECT COUNT(1) as count
|
SELECT COUNT(1) as count
|
||||||
FROM sounds
|
FROM sounds
|
||||||
WHERE uploader_id = ?
|
WHERE uploader_id = ?",
|
||||||
",
|
|
||||||
user_id
|
user_id
|
||||||
)
|
)
|
||||||
.fetch_one(db_pool)
|
.fetch_one(db_pool)
|
||||||
@ -491,12 +478,11 @@ SELECT COUNT(1) as count
|
|||||||
|
|
||||||
let c = sqlx::query!(
|
let c = sqlx::query!(
|
||||||
"
|
"
|
||||||
SELECT COUNT(1) as count
|
SELECT COUNT(1) as count
|
||||||
FROM sounds
|
FROM sounds
|
||||||
WHERE
|
WHERE
|
||||||
uploader_id = ? AND
|
uploader_id = ? AND
|
||||||
name = ?
|
name = ?",
|
||||||
",
|
|
||||||
user_id,
|
user_id,
|
||||||
name
|
name
|
||||||
)
|
)
|
||||||
@ -513,12 +499,11 @@ SELECT COUNT(1) as count
|
|||||||
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
"
|
"
|
||||||
UPDATE sounds
|
UPDATE sounds
|
||||||
SET
|
SET
|
||||||
public = ?
|
public = ?
|
||||||
WHERE
|
WHERE
|
||||||
id = ?
|
id = ?",
|
||||||
",
|
|
||||||
self.public,
|
self.public,
|
||||||
self.id
|
self.id
|
||||||
)
|
)
|
||||||
@ -619,9 +604,8 @@ WHERE
|
|||||||
Some(data) => {
|
Some(data) => {
|
||||||
match sqlx::query!(
|
match sqlx::query!(
|
||||||
"
|
"
|
||||||
INSERT INTO sounds (name, server_id, uploader_id, public, src)
|
INSERT INTO sounds (name, server_id, uploader_id, public, src)
|
||||||
VALUES (?, ?, ?, 1, ?)
|
VALUES (?, ?, ?, 1, ?)",
|
||||||
",
|
|
||||||
name,
|
name,
|
||||||
server_id,
|
server_id,
|
||||||
user_id,
|
user_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user