Skip to content

Commit 3bf2394

Browse files
committed
Added log link command
1 parent d42532f commit 3bf2394

File tree

6 files changed

+31
-7
lines changed

6 files changed

+31
-7
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
# v2.11.0
8+
9+
### Added
10+
11+
- `loglink` command, returns the log link for the current thread.
12+
713
# v2.10.2
814
- Your logs now track and show edited messages.
915

bot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
SOFTWARE.
2323
"""
2424

25-
__version__ = '2.10.2'
25+
__version__ = '2.11.0'
2626

2727
import asyncio
2828
import uvloop

cogs/modmail.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,16 @@ async def nsfw(self, ctx):
302302
return
303303
await ctx.channel.edit(nsfw=True)
304304
await ctx.message.add_reaction('✅')
305+
306+
@commands.command()
307+
async def loglink(self, ctx):
308+
thread = await self.bot.threads.find(channel=ctx.channel)
309+
if thread:
310+
log_link = await self.bot.modmail_api.get_log_link(ctx.channel.id)
311+
await ctx.send(embed=discord.Embed(
312+
color=discord.Color.blurple(),
313+
description=log_link)
314+
)
305315

306316
@commands.command(aliases=['threads'])
307317
@commands.has_permissions(manage_messages=True)

core/clients.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ def get_user_logs(self, user_id):
122122

123123
def get_log(self, channel_id):
124124
return self.request(self.logs + '/' + str(channel_id))
125+
126+
async def get_log_link(self, channel_id):
127+
doc = await self.get_log(channel_id)
128+
return f'https://logs.modmail.tk/{doc["key"]}'
125129

126130
def get_config(self):
127131
return self.request(self.config)
@@ -131,7 +135,7 @@ def update_config(self, data):
131135
data = {k: v for k, v in data.items() if k in valid_keys}
132136
return self.request(self.config, method='PATCH', payload=data)
133137

134-
def get_log_url(self, recipient, channel, creator):
138+
def create_log_entry(self, recipient, channel, creator):
135139
return self.request(self.logs + '/key', payload={
136140
'channel_id': str(channel.id),
137141
'guild_id': str(self.app.guild_id),
@@ -218,8 +222,13 @@ async def get_user_logs(self, user_id):
218222

219223
async def get_log(self, channel_id):
220224
return await self.logs.find_one({'channel_id': str(channel_id)})
225+
226+
async def get_log_link(self, channel_id):
227+
doc = await self.get_log(channel_id)
228+
key = doc['key']
229+
return f"{self.app.config.log_url.strip('/')}/logs/{key}"
221230

222-
async def get_log_url(self, recipient, channel, creator):
231+
async def create_log_entry(self, recipient, channel, creator):
223232
key = secrets.token_hex(6)
224233

225234
await self.logs.insert_one({

core/config.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ class ConfigManager:
77
"""Class that manages a cached configuration"""
88

99
allowed_to_change_in_command = {
10-
'activity_message', 'activity_type', 'log_channel_id',
11-
'mention', 'disable_autoupdates', 'prefix',
10+
'log_channel_id', 'mention', 'disable_autoupdates', 'prefix',
1211
'main_category_id', 'sent_emoji', 'blocked_emoji',
1312
'thread_creation_response', 'twitch_url', 'mod_color',
1413
'recipient_color', 'mod_tag', 'anon_username', 'anon_avatar_url',
@@ -18,7 +17,7 @@ class ConfigManager:
1817
internal_keys = {
1918
'snippets', 'aliases', 'blocked',
2019
'notification_squad', 'subscriptions',
21-
'closures'
20+
'closures', 'activity_message', 'activity_type'
2221
}
2322

2423
protected_keys = {

core/thread.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ async def create(self, recipient, *, creator=None, category=None):
477477
thread.channel = channel
478478

479479
log_url, log_data = await asyncio.gather(
480-
self.bot.modmail_api.get_log_url(recipient, channel, creator or recipient),
480+
self.bot.modmail_api.create_log_entry(recipient, channel, creator or recipient),
481481
self.bot.modmail_api.get_user_logs(recipient.id)
482482
# self.get_dominant_color(recipient.avatar_url)
483483
)

0 commit comments

Comments
 (0)