Skip to content

Commit a01da8f

Browse files
Merge pull request #321 from RemainingDelta/318-Enhancement
318-Enhancement replace previous cleanup warning instead of stacking a new one
2 parents 0ead0f4 + 4974f32 commit a01da8f

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

features/event.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ async def cancel(self, interaction: discord.Interaction, button: discord.ui.Butt
296296
class Events(commands.Cog):
297297
def __init__(self, bot):
298298
self.bot = bot
299+
self._warning_msg_ids: dict[int, int] = {} # channel_id → warning message_id
299300
self.cleanup_check_task.start()
300301

301302
def cog_unload(self):
@@ -415,8 +416,17 @@ async def cleanup_check_task(self):
415416
inline=False,
416417
)
417418

419+
old_msg_id = self._warning_msg_ids.get(channel_id)
420+
if old_msg_id:
421+
try:
422+
old_msg = await staff_channel.fetch_message(old_msg_id)
423+
await old_msg.delete()
424+
except (discord.NotFound, discord.HTTPException):
425+
pass
426+
418427
view = ClearChannelView(channel_id)
419-
await staff_channel.send(embed=embed, view=view)
428+
new_msg = await staff_channel.send(embed=embed, view=view)
429+
self._warning_msg_ids[channel_id] = new_msg.id
420430
print(f"⚠️ Sent cleanup alert for #{name}-event")
421431

422432
break

0 commit comments

Comments
 (0)