mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[Audio] Disallow all users from modifying Playlist 42069. (#5018)
This commit is contained in:
parent
c36665e755
commit
00d2d62f1b
@ -322,7 +322,13 @@ class MixinMeta(ABC):
|
|||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
async def can_manage_playlist(
|
async def can_manage_playlist(
|
||||||
self, scope: str, playlist: "Playlist", ctx: commands.Context, user, guild
|
self,
|
||||||
|
scope: str,
|
||||||
|
playlist: "Playlist",
|
||||||
|
ctx: commands.Context,
|
||||||
|
user,
|
||||||
|
guild,
|
||||||
|
bypass: bool = False,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
|||||||
@ -1676,9 +1676,11 @@ class PlaylistCommands(MixinMeta, metaclass=CompositeMetaClass):
|
|||||||
ctx.command.reset_cooldown(ctx)
|
ctx.command.reset_cooldown(ctx)
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
if not await self.can_manage_playlist(scope, playlist, ctx, author, guild):
|
if not await self.can_manage_playlist(
|
||||||
|
scope, playlist, ctx, author, guild, bypass=True
|
||||||
|
):
|
||||||
return
|
return
|
||||||
if playlist.url or playlist.id == 42069:
|
if playlist.url or getattr(playlist, "id", 0) == 42069:
|
||||||
player = lavalink.get_player(ctx.guild.id)
|
player = lavalink.get_player(ctx.guild.id)
|
||||||
added, removed, playlist = await self._maybe_update_playlist(
|
added, removed, playlist = await self._maybe_update_playlist(
|
||||||
ctx, player, playlist
|
ctx, player, playlist
|
||||||
|
|||||||
@ -39,7 +39,13 @@ CURRATED_DATA = (
|
|||||||
|
|
||||||
class PlaylistUtilities(MixinMeta, metaclass=CompositeMetaClass):
|
class PlaylistUtilities(MixinMeta, metaclass=CompositeMetaClass):
|
||||||
async def can_manage_playlist(
|
async def can_manage_playlist(
|
||||||
self, scope: str, playlist: Playlist, ctx: commands.Context, user, guild
|
self,
|
||||||
|
scope: str,
|
||||||
|
playlist: Playlist,
|
||||||
|
ctx: commands.Context,
|
||||||
|
user,
|
||||||
|
guild,
|
||||||
|
bypass: bool = False,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
is_owner = await self.bot.is_owner(ctx.author)
|
is_owner = await self.bot.is_owner(ctx.author)
|
||||||
has_perms = False
|
has_perms = False
|
||||||
@ -54,8 +60,9 @@ class PlaylistUtilities(MixinMeta, metaclass=CompositeMetaClass):
|
|||||||
|
|
||||||
is_different_user = len({playlist.author, user_to_query.id, ctx.author.id}) != 1
|
is_different_user = len({playlist.author, user_to_query.id, ctx.author.id}) != 1
|
||||||
is_different_guild = True if guild_to_query is None else ctx.guild.id != guild_to_query.id
|
is_different_guild = True if guild_to_query is None else ctx.guild.id != guild_to_query.id
|
||||||
|
if getattr(playlist, "id", 0) == 42069:
|
||||||
if is_owner:
|
has_perms = bypass
|
||||||
|
elif is_owner:
|
||||||
has_perms = True
|
has_perms = True
|
||||||
elif playlist.scope == PlaylistScope.USER.value:
|
elif playlist.scope == PlaylistScope.USER.value:
|
||||||
if not is_different_user:
|
if not is_different_user:
|
||||||
@ -476,7 +483,7 @@ class PlaylistUtilities(MixinMeta, metaclass=CompositeMetaClass):
|
|||||||
async def _maybe_update_playlist(
|
async def _maybe_update_playlist(
|
||||||
self, ctx: commands.Context, player: lavalink.player_manager.Player, playlist: Playlist
|
self, ctx: commands.Context, player: lavalink.player_manager.Player, playlist: Playlist
|
||||||
) -> Tuple[List[lavalink.Track], List[lavalink.Track], Playlist]:
|
) -> Tuple[List[lavalink.Track], List[lavalink.Track], Playlist]:
|
||||||
if playlist.id == 42069:
|
if getattr(playlist, "id", 0) == 42069:
|
||||||
_, updated_tracks = await self._get_bundled_playlist_tracks()
|
_, updated_tracks = await self._get_bundled_playlist_tracks()
|
||||||
results = {}
|
results = {}
|
||||||
old_tracks = playlist.tracks_obj
|
old_tracks = playlist.tracks_obj
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user