Change to require dj permission for join with channel id

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/9/head
trivernis 3 years ago
parent 87cfba1bc8
commit 8ed7cf90b3
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

4
Cargo.lock generated

@ -205,7 +205,7 @@ dependencies = [
[[package]]
name = "bot-serenityutils"
version = "0.1.0"
version = "0.2.0"
dependencies = [
"futures",
"log 0.4.14",
@ -2282,7 +2282,7 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tobi-rs"
version = "0.3.0"
version = "0.4.0"
dependencies = [
"aspotify",
"bot-coreutils",

@ -1,6 +1,6 @@
[package]
name = "tobi-rs"
version = "0.3.0"
version = "0.4.0"
authors = ["trivernis <trivernis@protonmail.com>"]
edition = "2018"

@ -68,7 +68,7 @@ dependencies = [
[[package]]
name = "bot-serenityutils"
version = "0.1.0"
version = "0.2.0"
dependencies = [
"futures",
"log",

@ -1,6 +1,6 @@
[package]
name = "bot-serenityutils"
version = "0.1.0"
version = "0.2.0"
authors = ["trivernis <trivernis@protonmail.com>"]
edition = "2018"

@ -4,7 +4,7 @@ use serenity::framework::standard::{Args, CommandResult};
use serenity::model::channel::Message;
use crate::commands::common::handle_autodelete;
use crate::commands::music::{get_channel_for_author, join_channel};
use crate::commands::music::{get_channel_for_author, is_dj, join_channel};
use serenity::model::id::ChannelId;
#[command]
@ -15,7 +15,11 @@ use serenity::model::id::ChannelId;
async fn join(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
let guild = msg.guild(&ctx.cache).await.unwrap();
let channel_id = if let Ok(arg) = args.single::<u64>() {
ChannelId(arg)
if is_dj(ctx, guild.id, &msg.author).await? {
ChannelId(arg)
} else {
get_channel_for_author(&msg.author.id, &guild)?
}
} else {
get_channel_for_author(&msg.author.id, &guild)?
};

Loading…
Cancel
Save