From 252fdeddec87ba52ac41182906afe8d6a3efa09d Mon Sep 17 00:00:00 2001 From: flifloo Date: Thu, 30 Jul 2020 11:25:01 +0200 Subject: [PATCH] Send greetings join message on guild system channel if user block pm --- extensions/greetings.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/extensions/greetings.py b/extensions/greetings.py index 71e7b92..1c3b0ce 100644 --- a/extensions/greetings.py +++ b/extensions/greetings.py @@ -1,5 +1,5 @@ from discord.ext import commands -from discord import Member, Embed +from discord import Member, Embed, Forbidden from discord.ext.commands import BadArgument from administrator.logger import logger @@ -87,7 +87,11 @@ class Greetings(commands.Cog): m = s.query(db.Greetings).filter(db.Greetings.guild == member.guild.id).first() s.close() if m and m.join_enable: - await member.send(embed=m.join_embed(member.guild.name, str(member))) + embed = m.join_embed(member.guild.name, str(member)) + try: + await member.send(embed=embed) + except Forbidden: + await member.guild.system_channel.send(member.mention, embed=embed) @commands.Cog.listener() async def on_member_remove(self, member: Member):