1
0
Fork 0

Send greetings join message on guild system channel if user block pm

This commit is contained in:
Ethanell 2020-07-30 11:25:01 +02:00
parent 585f3e59d5
commit 252fdeddec

View file

@ -1,5 +1,5 @@
from discord.ext import commands from discord.ext import commands
from discord import Member, Embed from discord import Member, Embed, Forbidden
from discord.ext.commands import BadArgument from discord.ext.commands import BadArgument
from administrator.logger import logger 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() m = s.query(db.Greetings).filter(db.Greetings.guild == member.guild.id).first()
s.close() s.close()
if m and m.join_enable: 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() @commands.Cog.listener()
async def on_member_remove(self, member: Member): async def on_member_remove(self, member: Member):