Skip to content

Commit 158e459

Browse files
committed
Check if channel is already archived
1 parent 56ee85a commit 158e459

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

bot.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,22 +300,29 @@ async def archive(self, ctx):
300300
deleteing the channel.)
301301
'''
302302
user_id = None
303+
303304
if not ctx.channel.topic:
304305
user_id = await self.find_user_id_from_channel(ctx.channel)
305306
elif 'User ID:' not in str(ctx.channel.topic) and not user_id:
306307
return await ctx.send('This is not a modmail thread.')
307308

308309
user_id = user_id or int(ctx.channel.topic.split(': ')[1])
310+
311+
archives = discord.utils.get(ctx.guild.categories, name='Mod Mail Archives')
312+
313+
if ctx.channel.category is archives:
314+
return await ctx.send('This channel is already archived.')
315+
309316
user = self.get_user(user_id)
310317
em = discord.Embed(title='Thread Closed')
311318
em.description = f'{ctx.author.mention} has closed this modmail session.'
312319
em.color = discord.Color.red()
320+
313321
try:
314322
await user.send(embed=em)
315323
except:
316324
pass
317325

318-
archives = discord.utils.get(ctx.guild.categories, name='Mod Mail Archives')
319326
await ctx.channel.edit(category=archives)
320327
done = discord.Embed(title='Thread Archived')
321328
done.description = f'{ctx.author.mention} has archived this modmail session.'

0 commit comments

Comments
 (0)