From 5566779d4e1e1bcde03408d6bae84541d9da4888 Mon Sep 17 00:00:00 2001 From: "Nyeki.py" <84998222+Nekidev@users.noreply.github.com> Date: Sun, 3 Nov 2024 00:39:50 -0300 Subject: [PATCH] feat(bot): :coffin: Remove `p.shutdown` command. --- payphone/cogs/mods/cog.py | 93 --------------------------------------- 1 file changed, 93 deletions(-) diff --git a/payphone/cogs/mods/cog.py b/payphone/cogs/mods/cog.py index e633578..97666c0 100644 --- a/payphone/cogs/mods/cog.py +++ b/payphone/cogs/mods/cog.py @@ -228,99 +228,6 @@ class Mods(base.Cog): f"✅ **{profile_row.name}**'s moderator status was set to `{"on" if user_row.is_moderator else "off"}`." ) - @commands.command(aliases=["restart"]) - @commands.is_owner() - @transactions.atomic() - async def shutdown( - self, ctx: commands.Context, seconds: int = 60, *, reason: str | None - ) -> None: - """ - Notifies all the in-call users of the scheduled shutdown and shuts down Payphone after x seconds. - - Options: - - `[]`: The amount of seconds to wait before shutdown. - - `[]`: The reason of the shutdown. - """ - - if seconds > 0: - oncall_channel_ids = list( - await self.bot.redis.smembers(constants.CHANNELS_ONCALL_SET) - ) - searching_channel_ids = list( - await self.bot.redis.smembers(constants.CHANNELS_SEARCH_QUEUE) - ) - - channel_ids = [int(c) for c in oncall_channel_ids] + [ - int(c) for c in searching_channel_ids - ] - - await ctx.send( - f"⚡ Notifying `{len(channel_ids)}` channels of the shutdown." - ) - - for channel_id in channel_ids: - try: - await self.bot.get_partial_messageable(channel_id).send( - f"⚡ Payphone will be shutdown due to a maintenance restart." - + (" Reason: " + reason if reason is not None else "") - ) - - except errors.DiscordException: - pass - - await ctx.send( - f"⚡ All channels were notified of the shutdown. Payphone will shut down ." - ) - - await asyncio.sleep(seconds) - - oncall_channel_ids = list( - await self.bot.redis.smembers(constants.CHANNELS_ONCALL_SET) - ) - searching_channel_ids = list( - await self.bot.redis.smembers(constants.CHANNELS_SEARCH_QUEUE) - ) - - channel_ids = [int(c) for c in oncall_channel_ids] + [ - int(c) for c in searching_channel_ids - ] - - await ctx.send(f"⚡ Notifying `{len(channel_ids)}` channels of hang up.") - - for channel_id in channel_ids: - try: - await self.bot.get_partial_messageable(channel_id).send( - "⚡ The call will be ended due to a scheduled shutdown." - ) - - except errors.DiscordException: - pass - - await ctx.send( - "⚡ Notified all channels of calls hang up. Updating Payphone's status..." - ) - - await self.bot.change_presence( - activity=discord.CustomActivity(name="Payphone is restarting."), - status=discord.Status.do_not_disturb, - ) - - await self.bot.redis.delete(constants.CHANNELS_ONCALL_SET) - - calls = await models.Call.filter(ended_at=None) - - call_ids = [call.id for call in calls] - if call_ids: - await self.bot.redis.sadd(constants.CALL_IDS_TO_FLUSH, *call_ids) - - await models.Call.filter(ended_at=None).update( - ended_at=datetime.now(timezone.utc) - ) - - await flush_messages.flush() - - await ctx.send("⚡ Messages were flushed, payphone is ready to shut down.") - @commands.command() @commands.is_owner() async def stats(