Skip to content

Commit 85a0828

Browse files
committed
Allow custom log channel via config var
1 parent f1a679a commit 85a0828

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@ 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+
8+
# [ unreleased ]
9+
10+
Improvements in commands and new config option available.
11+
12+
### Added
13+
- Added the ability to use your own log channel
14+
- You can do this by using the `config set log_channel_id <id>` command.
15+
16+
### Changed
17+
- You now have the ability to supply a reason when blocking a user.
18+
- Blocked users are now stored in the database instead of in the channel topic.
19+
- This means you can delete the top channel in the modmail category now.
20+
21+
722
# v2.0.7
823

924
New command and improvements in bot update message interfaces.

bot.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ def run(self):
9191
super().run(self.token)
9292
finally:
9393
print(Fore.RED + ' - Shutting down bot' + Style.RESET_ALL)
94+
95+
@property
96+
def log_channel(self):
97+
channel_id = self.config.get('bot_log_channel_id')
98+
if channel_id is not None:
99+
return self.get_channel(int(channel_id))
100+
else:
101+
return self.main_category.channels[0]
94102

95103
@property
96104
def snippets(self):
@@ -167,7 +175,7 @@ async def on_ready(self):
167175
{Fore.CYAN}Guild ID: {self.guild.id if self.guild else 0}
168176
{line}
169177
""").strip())
170-
178+
171179
if not self.guild:
172180
print(Fore.RED + Style.BRIGHT + 'WARNING - The GUILD_ID provided does not exist!' + Style.RESET_ALL)
173181
else:
@@ -292,7 +300,7 @@ async def on_guild_channel_delete(self, channel):
292300
desc = f"[`{log_data['key']}`]({log_url}) {mod.mention} closed a thread with {user}"
293301
em = discord.Embed(description=desc, color=em.color)
294302
em.set_author(name='Thread closed', url=log_url)
295-
await self.main_category.channels[0].send(embed=em)
303+
await self.log_channel.send(embed=em)
296304

297305
async def on_message_delete(self, message):
298306
"""Support for deleting linked messages"""

cogs/modmail.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ async def _close(self, ctx):
138138
pass
139139

140140
# Logging
141-
categ = self.bot.main_category
142-
log_channel = categ.channels[0]
141+
log_channel = self.bot.log_channel
143142

144143
log_data = await self.bot.modmail_api.post_log(ctx.channel.id, {
145144
'open': False, 'closed_at': str(datetime.datetime.utcnow()), 'closer': {

0 commit comments

Comments
 (0)