Skip to content

Commit e51758e

Browse files
committed
Improved contact command
1 parent e7de453 commit e51758e

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

bot.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
SOFTWARE.
2323
'''
2424

25-
__version__ = '1.3.5'
25+
__version__ = '1.3.6'
2626

2727
import discord
2828
from discord.ext import commands
@@ -590,7 +590,7 @@ async def process_reply(self, message, user_id=None):
590590
user_id = user_id or int(re.findall(r'\d+', message.channel.topic)[0])
591591
user = self.get_user(user_id)
592592
if not user:
593-
return await message.channel.send('This user does not have any mutual servers with the bot and is thus unreachable.')
593+
return await message.channel.send('This user does not share any servers with the bot and is thus unreachable.')
594594
await asyncio.gather(
595595
self.send_mail(message, message.channel, from_mod=True),
596596
self.send_mail(message, user, from_mod=True)
@@ -637,7 +637,7 @@ async def process_modmail(self, message):
637637
await self.send_mail(message, channel, from_mod=False)
638638

639639

640-
async def create_thread(self, user, *, creator=None):
640+
async def create_thread(self, user, *, creator=None, reopen=False):
641641

642642
guild = self.guild
643643
topic = f'User ID: {user.id}'
@@ -653,10 +653,13 @@ async def create_thread(self, user, *, creator=None):
653653

654654
if creator:
655655
em = discord.Embed(title='Modmail thread started')
656-
em.description = f'{creator.mention} has started a modmail thread with you.'
656+
second = 'has started a modmail thread with you.' if not reopen else 'has reopened this modmail thread.'
657+
em.description = f'{creator.mention} ' + second
658+
657659
em.color = discord.Color.green()
658660

659-
info_description = f'{creator.mention} has created a thread with {user.mention}'
661+
info_description = f'{creator.mention} has {"created" if not reopen else "reopened"} a thread with {user.mention}'
662+
660663

661664
mention = (self.config.get('MENTION') or '@here') if not creator else None
662665

@@ -703,13 +706,24 @@ async def reply(self, ctx, *, msg=''):
703706

704707
@commands.command()
705708
@commands.has_permissions(manage_channels=True)
706-
async def contact(self, ctx, *, user: discord.Member):
709+
async def contact(self, ctx, *, user: discord.Member=None):
707710
'''Create a thread with a specified member.'''
711+
reopen = False
712+
if not user and ctx.channel.category and ctx.channel.category.name == 'Mod Mail Archives':
713+
user_id = None
714+
if not ctx.channel.topic:
715+
user_id = await self.find_user_id_from_channel(ctx.channel)
716+
user_id = user_id or int(ctx.channel.topic.split(': ')[1])
717+
user = self.get_user(user_id)
718+
reopen = True
719+
if not user:
720+
return await ctx.send('This user does not share any servers with the bot and is thus unreachable.')
721+
708722
categ = discord.utils.get(ctx.guild.categories, id=ctx.channel.category_id)
709-
channel = await self.create_thread(user, creator=ctx.author)
723+
channel = await self.create_thread(user, creator=ctx.author, reopen=reopen)
710724

711-
em = discord.Embed(title='Created Thread')
712-
em.description = f'Thread started in {channel.mention} for {user.mention}'
725+
em = discord.Embed(title='Thread reopened' if reopen else 'Created thread')
726+
em.description = f'Thread {"reopned" if reopen else "started"} in {channel.mention} for {user.mention}'
713727
em.color = discord.Color.green()
714728

715729
await ctx.send(embed=em)

0 commit comments

Comments
 (0)