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
|
self.bot.scheduled_shutdown.value = True
|
||||||
|
|
||||||
oncall_channel_ids = list(
|
if seconds > 0:
|
||||||
await self.bot.redis.smembers(constants.CHANNELS_ONCALL_SET)
|
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)
|
searching_channel_ids = list(
|
||||||
)
|
await self.bot.redis.smembers(constants.CHANNELS_SEARCH_QUEUE)
|
||||||
|
)
|
||||||
|
|
||||||
channel_ids = [int(c) for c in oncall_channel_ids] + [
|
channel_ids = [int(c) for c in oncall_channel_ids] + [
|
||||||
int(c) for c in searching_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:
|
for channel_id in channel_ids:
|
||||||
try:
|
try:
|
||||||
await self.bot.get_partial_messageable(channel_id).send(
|
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."
|
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 "")
|
+ (" Reason: " + reason if reason is not None else "")
|
||||||
)
|
)
|
||||||
|
|
||||||
except errors.DiscordException:
|
except errors.DiscordException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
await ctx.send(
|
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>."
|
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(
|
oncall_channel_ids = list(
|
||||||
await self.bot.redis.smembers(constants.CHANNELS_ONCALL_SET)
|
await self.bot.redis.smembers(constants.CHANNELS_ONCALL_SET)
|
||||||
@@ -302,7 +305,7 @@ class Mods(base.Cog):
|
|||||||
|
|
||||||
await self.bot.change_presence(
|
await self.bot.change_presence(
|
||||||
activity=discord.CustomActivity(name="Payphone is restarting."),
|
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)
|
await self.bot.redis.delete(constants.CHANNELS_ONCALL_SET)
|
||||||
|
|||||||
Reference in New Issue
Block a user