lunarflu HF staff commited on
Commit
270b41a
1 Parent(s): fc129e3
Files changed (1) hide show
  1. app.py +24 -37
app.py CHANGED
@@ -150,47 +150,34 @@ async def on_member_update(before, after):
150
 
151
 
152
  @bot.event
153
- async def on_member_ban(guild, user):
154
  try:
155
- """
156
- print("1")
157
- async for entry in guild.audit_logs(limit=5, action=discord.AuditLogAction.ban):
158
- print("2")
159
- if entry.target == user:
160
- print("3")
161
- account_age = datetime.utcnow() - user.created_at
162
- created_and_age = f"{user.created_at} ({account_age})"
163
- reason = f"Reason: {entry.reason}" if entry.reason else "No reason provided."
164
- content = "<@&1108342563628404747>" # @alerts role
165
- print("4")
166
- embed = Embed(color=Color.red())
167
- embed.set_author(name=f"{user} ID: {user.id}", icon_url=user.avatar.url)
168
- embed.title = "User Banned"
169
- embed.add_field(name="User", value=user.mention, inline=True)
170
- embed.add_field(name="Nickname", value=user.nick, inline=True)
171
- embed.add_field(name="Account Age", value=created_and_age, inline=True)
172
- embed.add_field(name="Moderator", value=entry.user.mention, inline=True)
173
- embed.add_field(name="Nickname", value=entry.user.nick, inline=True)
174
- embed.add_field(name="Reason", value=reason, inline=False)
175
- embed.set_footer(text=f"{convert_to_timezone(datetime.utcnow(), zurich_tz)}")
176
- print("5")
177
- await bot.log_channel.send(content=content, embed=embed)
178
-
179
- """
180
-
181
 
182
- # member banned from the guild
183
- embed = Embed(description=f'Member {user.mention} was banned from the guild', color=Color.red())
184
- await bot.log_channel.send(embed=embed)
185
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
 
187
  except Exception as e:
188
- print(f"Error: {e}")
189
-
190
- """
191
- async for entry in before.guild.audit_logs(limit=5):
192
- print(f'{entry.user} did {entry.action} to {entry.target}') (and add reason if it exists)
193
- """
194
 
195
 
196
  @bot.event
 
150
 
151
 
152
  @bot.event
153
+ async def on_member_ban(guild, banned_user):
154
  try:
155
+ entry = await guild.fetch_ban(banned_user)
156
+ ban_reason = entry.reason
157
+ print(f"ban_reason: {ban_reason}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
 
159
+ async for entry in guild.audit_logs(action=discord.AuditLogAction.ban, limit=1):
160
+ moderator = entry.user
161
+ print(f"moderator: {moderator}")
162
+
163
+ #ban_reason = f"Reason: {ban_reason}"
164
+ # HF 1108342563628404747
165
+ # test 1106995261487710411
166
+ content = "<@&1108342563628404747>" # @alerts role
167
+ embed = Embed(color=Color.red())
168
+ embed.set_author(name=f"{banned_user} ID: {banned_user.id}", icon_url=banned_user.avatar.url)
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