Skip to content

Commit

Permalink
close_on_leave config, resolves #2757
Browse files Browse the repository at this point in the history
  • Loading branch information
fourjr committed Nov 4, 2020
1 parent 306a158 commit d0bcaf1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
11 changes: 7 additions & 4 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,10 +1059,13 @@ async def on_member_remove(self, member):
return
thread = await self.threads.find(recipient=member)
if thread:
embed = discord.Embed(
description="The recipient has left the server.", color=self.error_color
)
await thread.channel.send(embed=embed)
if self.config["close_on_leave"]:
await thread.close(closer=member.guild.me, message="The recipient has left the server.", silent=True)
else:
embed = discord.Embed(
description="The recipient has left the server.", color=self.error_color
)
await thread.channel.send(embed=embed)

async def on_member_join(self, member):
if member.guild != self.guild:
Expand Down
2 changes: 2 additions & 0 deletions core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class ConfigManager:
"disabled_current_thread_response": "We are not accepting any messages.",
"disabled_current_thread_footer": "Please try again later...",
"transfer_reactions": True,
"close_on_leave": False,
# moderation
"recipient_color": str(discord.Color.gold()),
"mod_color": str(discord.Color.green()),
Expand Down Expand Up @@ -142,6 +143,7 @@ class ConfigManager:
"thread_move_notify",
"thread_move_notify_mods",
"transfer_reactions",
"close_on_leave",
"enable_plugins",
"enable_eval",
}
Expand Down
8 changes: 8 additions & 0 deletions core/config_help.json
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,14 @@
],
"notes": []
},
"close_on_leave": {
"default": "No",
"description": "Closes a modmail thread upon user leave automatically",
"examples":[
"`{prefix}config set close_on_leave yes"
],
"notes": []
},
"modmail_guild_id": {
"default": "Fallback on `GUILD_ID`",
"description": "The ID of the discord server where the threads channels should be created (receiving server).",
Expand Down

0 comments on commit d0bcaf1

Please sign in to comment.