remove useless sutff, and change dj check order to ensure bot doesnt join VC for non DJ's

This commit is contained in:
Drapersniper
2020-09-30 11:37:54 +01:00
parent ce94689461
commit 0a94b4c796
2 changed files with 30 additions and 31 deletions

View File

@@ -34,7 +34,6 @@ class GlobalCacheWrapper:
self.session = session self.session = session
self.api_key = None self.api_key = None
self._handshake_token = "" self._handshake_token = ""
self._handshake_token = ""
self.has_api_key = None self.has_api_key = None
self._token: Mapping[str, str] = {} self._token: Mapping[str, str] = {}
self.cog = cog self.cog = cog
@@ -175,6 +174,8 @@ class GlobalCacheWrapper:
) as resp: ) as resp:
if resp.status == 200: if resp.status == 200:
search_response = await resp.json(loads=json.loads) search_response = await resp.json(loads=json.loads)
global_api_user.update(search_response)
global_api_user["fetched"] = True global_api_user["fetched"] = True
global_api_user["can_read"] = search_response.get("can_read", False)
global_api_user["can_post"] = search_response.get("can_post", False)
global_api_user["can_delete"] = search_response.get("can_delete", False)
return global_api_user return global_api_user

View File

@@ -50,6 +50,13 @@ class PlayerCommands(MixinMeta, metaclass=CompositeMetaClass):
return await self.send_embed_msg( return await self.send_embed_msg(
ctx, title=_("Unable To Play Tracks"), description=_("That track is not allowed.") ctx, title=_("Unable To Play Tracks"), description=_("That track is not allowed.")
) )
can_skip = await self._can_instaskip(ctx, ctx.author)
if guild_data["dj_enabled"] and not can_skip:
return await self.send_embed_msg(
ctx,
title=_("Unable To Play Tracks"),
description=_("You need the DJ role to queue tracks."),
)
if not self._player_check(ctx): if not self._player_check(ctx):
if self.lavalink_connection_aborted: if self.lavalink_connection_aborted:
msg = _("Connection to Lavalink has failed") msg = _("Connection to Lavalink has failed")
@@ -84,15 +91,7 @@ class PlayerCommands(MixinMeta, metaclass=CompositeMetaClass):
title=_("Unable To Play Tracks"), title=_("Unable To Play Tracks"),
description=_("Connection to Lavalink has not yet been established."), description=_("Connection to Lavalink has not yet been established."),
) )
can_skip = await self._can_instaskip(ctx, ctx.author)
if guild_data["dj_enabled"] and not can_skip:
return await self.send_embed_msg(
ctx,
title=_("Unable To Play Tracks"),
description=_("You need the DJ role to queue tracks."),
)
player = lavalink.get_player(ctx.guild.id) player = lavalink.get_player(ctx.guild.id)
player.store("channel", ctx.channel.id) player.store("channel", ctx.channel.id)
player.store("guild", ctx.guild.id) player.store("guild", ctx.guild.id)
await self._eq_check(ctx, player) await self._eq_check(ctx, player)
@@ -155,6 +154,13 @@ class PlayerCommands(MixinMeta, metaclass=CompositeMetaClass):
return await self.send_embed_msg( return await self.send_embed_msg(
ctx, title=_("Unable To Play Tracks"), description=_("That track is not allowed.") ctx, title=_("Unable To Play Tracks"), description=_("That track is not allowed.")
) )
can_skip = await self._can_instaskip(ctx, ctx.author)
if guild_data["dj_enabled"] and not can_skip:
return await self.send_embed_msg(
ctx,
title=_("Unable To Play Tracks"),
description=_("You need the DJ role to queue tracks."),
)
if not self._player_check(ctx): if not self._player_check(ctx):
if self.lavalink_connection_aborted: if self.lavalink_connection_aborted:
msg = _("Connection to Lavalink has failed") msg = _("Connection to Lavalink has failed")
@@ -189,15 +195,7 @@ class PlayerCommands(MixinMeta, metaclass=CompositeMetaClass):
title=_("Unable To Play Tracks"), title=_("Unable To Play Tracks"),
description=_("Connection to Lavalink has not yet been established."), description=_("Connection to Lavalink has not yet been established."),
) )
can_skip = await self._can_instaskip(ctx, ctx.author)
if guild_data["dj_enabled"] and not can_skip:
return await self.send_embed_msg(
ctx,
title=_("Unable To Play Tracks"),
description=_("You need the DJ role to queue tracks."),
)
player = lavalink.get_player(ctx.guild.id) player = lavalink.get_player(ctx.guild.id)
player.store("channel", ctx.channel.id) player.store("channel", ctx.channel.id)
player.store("guild", ctx.guild.id) player.store("guild", ctx.guild.id)
await self._eq_check(ctx, player) await self._eq_check(ctx, player)
@@ -419,6 +417,12 @@ class PlayerCommands(MixinMeta, metaclass=CompositeMetaClass):
).format(prefix=ctx.prefix), ).format(prefix=ctx.prefix),
) )
guild_data = await self.config.guild(ctx.guild).all() guild_data = await self.config.guild(ctx.guild).all()
if guild_data["dj_enabled"] and not await self._can_instaskip(ctx, ctx.author):
return await self.send_embed_msg(
ctx,
title=_("Unable To Play Tracks"),
description=_("You need the DJ role to queue tracks."),
)
if not self._player_check(ctx): if not self._player_check(ctx):
if self.lavalink_connection_aborted: if self.lavalink_connection_aborted:
msg = _("Connection to Lavalink has failed") msg = _("Connection to Lavalink has failed")
@@ -453,12 +457,6 @@ class PlayerCommands(MixinMeta, metaclass=CompositeMetaClass):
title=_("Unable To Play Tracks"), title=_("Unable To Play Tracks"),
description=_("Connection to Lavalink has not yet been established."), description=_("Connection to Lavalink has not yet been established."),
) )
if guild_data["dj_enabled"] and not await self._can_instaskip(ctx, ctx.author):
return await self.send_embed_msg(
ctx,
title=_("Unable To Play Tracks"),
description=_("You need the DJ role to queue tracks."),
)
player = lavalink.get_player(ctx.guild.id) player = lavalink.get_player(ctx.guild.id)
player.store("channel", ctx.channel.id) player.store("channel", ctx.channel.id)
@@ -534,6 +532,13 @@ class PlayerCommands(MixinMeta, metaclass=CompositeMetaClass):
@commands.mod_or_permissions(manage_guild=True) @commands.mod_or_permissions(manage_guild=True)
async def command_autoplay(self, ctx: commands.Context): async def command_autoplay(self, ctx: commands.Context):
"""Starts auto play.""" """Starts auto play."""
guild_data = await self.config.guild(ctx.guild).all()
if guild_data["dj_enabled"] and not await self._can_instaskip(ctx, ctx.author):
return await self.send_embed_msg(
ctx,
title=_("Unable To Play Tracks"),
description=_("You need the DJ role to queue tracks."),
)
if not self._player_check(ctx): if not self._player_check(ctx):
if self.lavalink_connection_aborted: if self.lavalink_connection_aborted:
msg = _("Connection to Lavalink has failed") msg = _("Connection to Lavalink has failed")
@@ -568,13 +573,6 @@ class PlayerCommands(MixinMeta, metaclass=CompositeMetaClass):
title=_("Unable To Play Tracks"), title=_("Unable To Play Tracks"),
description=_("Connection to Lavalink has not yet been established."), description=_("Connection to Lavalink has not yet been established."),
) )
guild_data = await self.config.guild(ctx.guild).all()
if guild_data["dj_enabled"] and not await self._can_instaskip(ctx, ctx.author):
return await self.send_embed_msg(
ctx,
title=_("Unable To Play Tracks"),
description=_("You need the DJ role to queue tracks."),
)
player = lavalink.get_player(ctx.guild.id) player = lavalink.get_player(ctx.guild.id)
player.store("channel", ctx.channel.id) player.store("channel", ctx.channel.id)