From cdea8ede7d241fbec55423a052b9f74f1e9caf0c Mon Sep 17 00:00:00 2001 From: kyb3r Date: Sun, 6 Jan 2019 18:09:32 +1100 Subject: [PATCH] The bot will tell you when a user is no longer in server when replying to a thread. --- CHANGELOG.md | 7 +++++++ bot.py | 7 ++++++- core/thread.py | 4 ++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 085b9d6780..f3a1fe7352 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +# v2.0.6 + +### Fixed +- Fix logs sending duplicated thread close logs. +- The bot will now tell you that a user is no longer in the server when you try to reply to a thread. + - Before this, it looked like you replied to the thread but in reality the message didnt get sent. + # v2.0.5 ### Changed diff --git a/bot.py b/bot.py index d27850f05f..063a3f2f50 100644 --- a/bot.py +++ b/bot.py @@ -167,7 +167,10 @@ async def on_ready(self): {line} """).strip()) - await self.threads.populate_cache() + if not self.guild: + print(Fore.RED + Style.BRIGHT + 'WARNING - The GUILD_ID provided does not exist!' + Style.RESET_ALL) + else: + await self.threads.populate_cache() async def process_modmail(self, message): """Processes messages sent to the bot.""" @@ -257,6 +260,8 @@ async def on_guild_channel_delete(self, channel): audit_logs = self.modmail_guild.audit_logs() entry = await audit_logs.find(lambda e: e.target.id == channel.id) mod = entry.user + if mod.bot: + return log_data = await self.modmail_api.post_log(channel.id, { 'open': False, diff --git a/core/thread.py b/core/thread.py index f55b53aa17..165eac2e44 100644 --- a/core/thread.py +++ b/core/thread.py @@ -66,8 +66,8 @@ def edit_message(self, message_id, message): async def reply(self, message): if not message.content and not message.attachments: raise commands.UserInputError - if not self.recipient: - return await message.channel.send('This user does not share any servers with the bot and is thus unreachable.') + if self.recipient not in self.bot.guild.members: + return await message.channel.send('This user is no longer in the server and is thus unreachable.') await asyncio.gather( self.send(message, self.channel, from_mod=True), # in thread channel self.send(message, self.recipient, from_mod=True) # to user