lunarflu HF staff commited on
Commit
34ac5e1
1 Parent(s): 270b41a

ban + unban

Browse files
Files changed (1) hide show
  1. app.py +27 -7
app.py CHANGED
@@ -169,23 +169,43 @@ async def on_member_ban(guild, banned_user):
169
  embed.title = "User Banned"
170
  embed.add_field(name="User", value=banned_user.mention, inline=True)
171
  embed.add_field(name="Nickname", value=banned_user.nick, inline=True)
172
- embed.add_field(name="Account Age", value=banned_user.created_at, inline=True)
173
- embed.add_field(name="Moderator", value=moderator, inline=True)
174
  embed.add_field(name="Nickname", value=moderator.nick, inline=True)
175
  embed.add_field(name="Reason", value=ban_reason, inline=False)
176
  embed.set_footer(text=f"{convert_to_timezone(datetime.utcnow(), zurich_tz)}")
177
- await bot.log_channel.send(content=content, embed=embed)
 
 
 
178
 
179
  except Exception as e:
180
  print(f"Error: {e}")
181
 
182
 
183
  @bot.event
184
- async def on_member_unban(guild, user):
185
  try:
186
- # member unbanned from the guild
187
- embed = Embed(description=f'Member {user.mention} was unbanned from the guild', color=Color.green())
188
- await bot.log_channel.send(embed=embed)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  except Exception as e:
190
  print(f"Error: {e}")
191
 
 
169
  embed.title = "User Banned"
170
  embed.add_field(name="User", value=banned_user.mention, inline=True)
171
  embed.add_field(name="Nickname", value=banned_user.nick, inline=True)
172
+ embed.add_field(name="Account Created At", value=banned_user.created_at, inline=True)
173
+ embed.add_field(name="Moderator", value=moderator.mention, inline=True)
174
  embed.add_field(name="Nickname", value=moderator.nick, inline=True)
175
  embed.add_field(name="Reason", value=ban_reason, inline=False)
176
  embed.set_footer(text=f"{convert_to_timezone(datetime.utcnow(), zurich_tz)}")
177
+
178
+ user = bot.get_user(811235357663297546)
179
+ dm_message = await user.send(content=content, embed=embed)
180
+ #await bot.log_channel.send(content=content, embed=embed)
181
 
182
  except Exception as e:
183
  print(f"Error: {e}")
184
 
185
 
186
  @bot.event
187
+ async def on_member_unban(guild, unbanned_user):
188
  try:
189
+ async for entry in guild.audit_logs(action=discord.AuditLogAction.unban, limit=1):
190
+ if unbanned_user == entry.target: # verify that unbanned user is in audit log
191
+ moderator = entry.user
192
+
193
+ created_and_age = f"{unbanned_user.created_at}"
194
+ content = "<@&1108342563628404747>" # @alerts role
195
+ embed = Embed(color=Color.red())
196
+ embed.set_author(name=f"{unbanned_user} ID: {unbanned_user.id}", icon_url=unbanned_user.avatar.url)
197
+ embed.title = "User Unbanned"
198
+ embed.add_field(name="User", value=unbanned_user.mention, inline=True)
199
+ embed.add_field(name="Nickname", value=unbanned_user.nick, inline=True)
200
+ embed.add_field(name="Account Created At", value=created_and_age, inline=True)
201
+ embed.add_field(name="Moderator", value=moderator.mention, inline=True)
202
+ embed.add_field(name="Nickname", value=moderator.nick, inline=True)
203
+ embed.set_footer(text=f"{convert_to_timezone(datetime.utcnow(), zurich_tz)}")
204
+
205
+ user = bot.get_user(811235357663297546)
206
+ dm_message = await user.send(content=content, embed=embed)
207
+ #await bot.log_channel.send(content=content, embed=embed)
208
+
209
  except Exception as e:
210
  print(f"Error: {e}")
211