Skip to content

Commit 6b0a698

Browse files
committed
Merge branch 'master' into update
2 parents e395d9c + 17e8d8d commit 6b0a698

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

bot.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,12 @@ async def on_message(self, message):
686686
if message.content.startswith(prefix):
687687
cmd = message.content[len(prefix):].strip()
688688
if cmd in self.snippets:
689-
message.content = f'{prefix}reply {self.snippets[cmd]}'
690-
689+
thread = await self.threads.find(channel=message.channel)
690+
snippet = self.snippets[cmd]
691+
if thread:
692+
snippet = snippet.format(recipient=thread.recipient)
693+
message.content = f'{prefix}reply {snippet}'
694+
691695
ctx = await self.get_context(message)
692696
if ctx.command:
693697
return await self.invoke(ctx)

cogs/modmail.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ async def setup(self, ctx):
7272
'Consider setting permission groups to give access '
7373
'to roles or users the ability to use Modmail.\n'
7474
f'Type `{self.bot.prefix}permissions` for more info.')
75-
if not self.bot.config.permissions:
75+
76+
if not self.bot.config.get('permissions'):
7677
await self.bot.update_perms(PermissionLevel.REGULAR, -1)
7778
await self.bot.update_perms(PermissionLevel.OWNER, ctx.author.id)
7879

@@ -593,6 +594,7 @@ async def anonreply(self, ctx, *, msg: str = ''):
593594
async with ctx.typing():
594595
await ctx.thread.reply(ctx.message, anonymous=True)
595596

597+
596598
@commands.command()
597599
@checks.has_permissions(PermissionLevel.SUPPORTER)
598600
@checks.thread_only()

core/thread.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def __init__(self, manager: 'ThreadManager',
3434
self._id = recipient.id
3535
self._recipient = recipient
3636
self._channel = channel
37+
self.genesis_message = None
3738
self._ready_event = asyncio.Event()
3839
self._close_task = None
3940

@@ -79,6 +80,8 @@ def ready(self, flag: bool):
7980
async def setup(self, *, creator=None, category=None):
8081
"""Create the thread channel and other io related initialisation tasks"""
8182

83+
self.bot.dispatch('thread_create', self)
84+
8285
recipient = self.recipient
8386

8487
# in case it creates a channel outside of category
@@ -123,17 +126,19 @@ async def setup(self, *, creator=None, category=None):
123126
else:
124127
mention = self.bot.config.get('mention', '@here')
125128

126-
async def send_info_embed():
129+
async def send_genesis_message():
127130
try:
128131
msg = await channel.send(mention, embed=info_embed)
129-
await msg.pin()
132+
self.bot.loop.create_task(msg.pin())
133+
self.genesis_message = msg
130134
except:
131135
pass
136+
finally:
137+
self.ready = True
138+
self.bot.dispatch('thread_ready', self)
132139

133140
await channel.edit(topic=topic)
134-
self.bot.loop.create_task(send_info_embed())
135-
136-
self.ready = True
141+
self.bot.loop.create_task(send_genesis_message())
137142

138143
# Once thread is ready, tell the recipient.
139144
thread_creation_response = self.bot.config.get(

0 commit comments

Comments
 (0)