Skip to content

Commit bb72cfc

Browse files
committed
(fix) Category not removed from calendar when deleted
1 parent 6566944 commit bb72cfc

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

cogs/calendar.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,25 @@ async def calendar_updater(self):
298298
print(f'Explosions! Calendar failed to update...')
299299
traceback.print_exc()
300300

301-
301+
@commands.Cog.listener()
302+
async def on_guild_channel_delete(self, channel):
303+
if not isinstance(channel, discord.CategoryChannel):
304+
return
305+
306+
cur.execute('SELECT * FROM calendar WHERE category_id = ?', (channel.id,))
307+
if not cur.fetchone():
308+
return
309+
310+
cat = get_categories(channel.guild)[channel.id]
311+
try:
312+
msg = await cat.fetch_message(channel.guild)
313+
await msg.delete()
314+
except:
315+
pass
316+
317+
cur.execute('DELETE FROM calendar WHERE category_id = ?', (cat.category_id,))
318+
db.commit()
319+
302320
@commands.Cog.listener()
303321
async def on_ready(self):
304322
#self.channel_name_updater.add_exception_type(Exception)

0 commit comments

Comments
 (0)