async def on_member_remove(self, member): """Called when member leaves a guild.""" # log event logging_channel_id = await self.bot.db.execute( "SELECT member_log_channel_id FROM logging_settings WHERE guild_id = %s", member.guild.id, one_value=True, ) if logging_channel_id: logging_channel = member.guild.get_channel(logging_channel_id) if logging_channel is not None: embed = discord.Embed(color=discord.Color.red()) embed.set_author(name=str(member), icon_url=member.avatar_url) await logging_channel.send(embed=embed) # goodbye message goodbye = await self.bot.db.execute( "SELECT channel_id, is_enabled, message_format FROM goodbye_settings WHERE guild_id = %s", member.guild.id, one_row=True, ) if goodbye: channel_id, is_enabled, message_format = goodbye if is_enabled: channel = member.guild.get_channel(channel_id) if channel is not None: if message_format is None: message_format = "Goodbye **{user}** {mention}" try: await channel.send( util.create_goodbye_message( member, member.guild, message_format)) except discord.errors.Forbidden: pass
async def goodbye_message(self, ctx, *, message): """ Change the goodbye message format. Use with "default" to reset to the default format. """ if message.lower() == "default": message = None await queries.update_setting(ctx, "goodbye_settings", "message_format", message) preview = util.create_goodbye_message(ctx.author, ctx.guild, message) await ctx.send( f":white_check_mark: New goodbye message format set:\n```{message}```Preview:\n\n{preview}" )