From 515ede8d0df89e40977462cfa2e8089738a4a6dc Mon Sep 17 00:00:00 2001 From: Sami <samip5@users.noreply.github.com> Date: Fri, 6 Jul 2018 12:15:14 +0300 Subject: [PATCH] Music: Updated the permissions check. --- Music-bot/cogs/music.py | 2 +- Music-bot/cogs/utils/checks.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Music-bot/cogs/music.py b/Music-bot/cogs/music.py index 23a2ed1..813d3c4 100644 --- a/Music-bot/cogs/music.py +++ b/Music-bot/cogs/music.py @@ -426,7 +426,7 @@ class Music: await ctx.send(f'**`{ctx.author}`**: Set the volume to **{vol}%**') @commands.command(name='stop') - @checks.song_requester_or_owner_or_dj() + @checks.music_stop_check() async def stop_(self, ctx): """Stop the currently playing song and destroy the player. !Warning! diff --git a/Music-bot/cogs/utils/checks.py b/Music-bot/cogs/utils/checks.py index ab78f4e..1c7230b 100644 --- a/Music-bot/cogs/utils/checks.py +++ b/Music-bot/cogs/utils/checks.py @@ -119,4 +119,25 @@ def song_requester_or_owner_or_dj(): f"permissions are not enough to use this command.") return False + return commands.check(predicate) + + +def music_stop_check(): + async def predicate(ctx): + is_owner = await ctx.bot.is_owner(ctx.author) + vc = ctx.voice_client + + if not vc or not vc.is_connected(): + await ctx.send('I am not currently connected to voice!') + + if ctx.message.author.name == vc.source.requester.name: + return True + elif is_owner: + return True + elif discord.utils.get(ctx.message.author.roles, name="DJ"): + return True + elif ctx.message.author != vc.source.requester or not discord.utils.get(ctx.message.author.roles, name="DJ"): + await ctx.send(f"You lack the permissions to use this command, sorry.") + return False + return commands.check(predicate) \ No newline at end of file -- GitLab