send message if user is banned discord.py
@commands.Cog.listener()
async def on_member_remove(self, member):
channel = self.bot.get_channel(805991434330570793)
try:
banned = await member.guild.fetch_ban(member)
except discord.NotFound:
banned = False
if banned:
await channel.send(f"{member} was just banned from the server.")
else:
await channel.send(f"{member} just left the server.")