diff options
| author | 2021-02-10 21:32:41 +0100 | |
|---|---|---|
| committer | 2021-02-10 21:32:41 +0100 | |
| commit | fb4484ee23a00f0660765675782f1bf44812ca4e (patch) | |
| tree | 10b7fe8dab587def76e9b469ffec1fdde1ad44e0 | |
| parent | Add redis rescheduling (diff) | |
Add permanent streaming command
| -rw-r--r-- | bot/exts/moderation/stream.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/bot/exts/moderation/stream.py b/bot/exts/moderation/stream.py index af0633bdb..46c68f74b 100644 --- a/bot/exts/moderation/stream.py +++ b/bot/exts/moderation/stream.py @@ -26,7 +26,7 @@ class Stream(commands.Cog): async def _remove_streaming_permission(self, schedule_user: discord.Member) -> None: """Remove streaming permission from Member.""" await self._delete_from_redis(schedule_user.id) - await schedule_user.remove_roles(discord.Object(Roles.video), reason="Temporary streaming access revoked") + await schedule_user.remove_roles(discord.Object(Roles.video), reason="Streaming access revoked") async def _add_to_redis_cache(self, user_id: int, timestamp: float) -> None: """Adds 'task' to redis cache.""" @@ -86,6 +86,29 @@ class Stream(commands.Cog): duration = format_infraction_with_duration(str(duration)) await ctx.send(f"{Emojis.check_mark} {user.mention} can now stream until {duration}.") + @commands.command(aliases=("pstream",)) + @commands.has_any_role(*STAFF_ROLES) + async def permanentstream( + self, + ctx: commands.Context, + user: discord.Member, + *_ + ) -> None: + """Permanently give user a streaming permission.""" + # Check if user already has streaming permission + already_allowed = any(Roles.video == role.id for role in user.roles) + if already_allowed: + if user.id in self.scheduler: + self.scheduler.cancel(user.id) + await self._delete_from_redis(user.id) + await ctx.send(f"{Emojis.check_mark} Moved temporary permission to permanent") + return + await ctx.send(f"{Emojis.cross_mark} This user can already stream.") + return + + await user.add_roles(discord.Object(Roles.video), reason="Permanent streaming access granted") + await ctx.send(f"{Emojis.check_mark} {user.mention} can now stream forever") + @commands.command(aliases=("unstream", )) @commands.has_any_role(*STAFF_ROLES) async def revokestream( |