feat(bot): ✨ Shut down directly on p.shutdown 0.
This commit is contained in:
+26
-23
@@ -245,34 +245,37 @@ class Mods(base.Cog):
|
||||
|
||||
self.bot.scheduled_shutdown.value = True
|
||||
|
||||
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)
|
||||
)
|
||||
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
|
||||
]
|
||||
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.")
|
||||
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 <t:{int((datetime.now(timezone.utc) + timedelta(seconds=seconds)).timestamp())}:R> due to a maintenance restart."
|
||||
+ (" Reason: " + reason if reason is not None else "")
|
||||
)
|
||||
for channel_id in channel_ids:
|
||||
try:
|
||||
await self.bot.get_partial_messageable(channel_id).send(
|
||||
f"⚡ Payphone will be shutdown <t:{int((datetime.now(timezone.utc) + timedelta(seconds=seconds)).timestamp())}:R> due to a maintenance restart."
|
||||
+ (" Reason: " + reason if reason is not None else "")
|
||||
)
|
||||
|
||||
except errors.DiscordException:
|
||||
pass
|
||||
except errors.DiscordException:
|
||||
pass
|
||||
|
||||
await ctx.send(
|
||||
f"⚡ All channels were notified of the shutdown. Payphone will shut down <t:{int((datetime.now(timezone.utc) + timedelta(seconds=seconds)).timestamp())}:R>."
|
||||
)
|
||||
await ctx.send(
|
||||
f"⚡ All channels were notified of the shutdown. Payphone will shut down <t:{int((datetime.now(timezone.utc) + timedelta(seconds=seconds)).timestamp())}:R>."
|
||||
)
|
||||
|
||||
await asyncio.sleep(seconds)
|
||||
await asyncio.sleep(seconds)
|
||||
|
||||
oncall_channel_ids = list(
|
||||
await self.bot.redis.smembers(constants.CHANNELS_ONCALL_SET)
|
||||
@@ -302,7 +305,7 @@ class Mods(base.Cog):
|
||||
|
||||
await self.bot.change_presence(
|
||||
activity=discord.CustomActivity(name="Payphone is restarting."),
|
||||
status=discord.Status.do_not_disturb
|
||||
status=discord.Status.do_not_disturb,
|
||||
)
|
||||
|
||||
await self.bot.redis.delete(constants.CHANNELS_ONCALL_SET)
|
||||
|
||||
Reference in New Issue
Block a user