forked from jmug/stoatchat
fix: bots in multiple voice channel logic (#544)
This commit is contained in:
@@ -22,23 +22,25 @@ async fn get_connection() -> Result<Conn> {
|
|||||||
pub async fn raise_if_in_voice(user: &User, channel_id: &str) -> Result<()> {
|
pub async fn raise_if_in_voice(user: &User, channel_id: &str) -> Result<()> {
|
||||||
let mut conn = get_connection().await?;
|
let mut conn = get_connection().await?;
|
||||||
|
|
||||||
if user.bot.is_some()
|
if user.bot.is_some() {
|
||||||
// bots can be in as many voice channels as it wants so we just check if its already connected to the one its trying to connect to
|
// bots can be in as many voice channels as it wants so we just check if its already connected to the one its trying to connect to
|
||||||
&& conn.sismember(format!("vc:{}", &user.id), channel_id)
|
if conn
|
||||||
|
.sismember(format!("vc:{}", &user.id), channel_id)
|
||||||
.await
|
.await
|
||||||
.to_internal_error()?
|
.to_internal_error()?
|
||||||
{
|
{
|
||||||
Err(create_error!(AlreadyConnected))
|
return Err(create_error!(AlreadyConnected));
|
||||||
|
};
|
||||||
} else if conn
|
} else if conn
|
||||||
.scard::<_, u32>(format!("vc:{}", &user.id)) // check if the current vc set is empty
|
.scard::<_, u32>(format!("vc:{}", &user.id)) // check if the current vc set is empty
|
||||||
.await
|
.await
|
||||||
.to_internal_error()?
|
.to_internal_error()?
|
||||||
> 0
|
> 0
|
||||||
{
|
{
|
||||||
Err(create_error!(AlreadyConnected))
|
return Err(create_error!(AlreadyConnected));
|
||||||
} else {
|
};
|
||||||
Ok(())
|
|
||||||
}
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn set_channel_node(channel: &str, node: &str) -> Result<()> {
|
pub async fn set_channel_node(channel: &str, node: &str) -> Result<()> {
|
||||||
|
|||||||
Reference in New Issue
Block a user