lunarflu HF staff commited on
Commit
b917408
1 Parent(s): 0c41d1b

Ban embed updates

Browse files
Files changed (1) hide show
  1. app.py +49 -15
app.py CHANGED
@@ -52,7 +52,7 @@ ping alerts for list of keywords
52
  - more alerts for more stuff?
53
 
54
  '''
55
- # stats stuff---------------------------------------------------------------------------------------------------------------------------------------------------------------
56
  number_of_messages = 0
57
 
58
  @bot.event
@@ -71,8 +71,8 @@ async def on_message(message):
71
  except Exception as e:
72
  print(f"Error: {e}")
73
 
74
- # moderation stuff----------------------------------------------------------------------------------------------------------------------------------------------------------
75
-
76
  @bot.event
77
  async def on_message_edit(before, after):
78
  try:
@@ -126,7 +126,7 @@ async def on_message_delete(message):
126
  except Exception as e:
127
  print(f"Error: {e}")
128
 
129
- # nickname stuff
130
  @bot.event
131
  async def on_member_update(before, after):
132
  try:
@@ -152,16 +152,39 @@ async def on_member_update(before, after):
152
  @bot.event
153
  async def on_member_ban(guild, user):
154
  try:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  """
156
- async for entry in before.guild.audit_logs(limit=5):
157
- print(f'{entry.user} did {entry.action} to {entry.target}') (and add reason if it exists)
158
- """
159
  # member banned from the guild
160
  embed = Embed(description=f'Member {user.mention} was banned from the guild', color=Color.red())
161
  await bot.log_channel.send(embed=embed)
 
 
162
  except Exception as e:
163
- print(f"Error: {e}")
164
-
 
 
 
 
 
165
 
166
  @bot.event
167
  async def on_member_unban(guild, user):
@@ -172,8 +195,7 @@ async def on_member_unban(guild, user):
172
  except Exception as e:
173
  print(f"Error: {e}")
174
 
175
-
176
- # admin stuff---------------------------------------------------------------------------------------------------------------------------------------------------------------
177
 
178
  @bot.event
179
  async def on_guild_channel_create(channel):
@@ -247,14 +269,26 @@ async def on_voice_state_update(member, before, after):
247
  except Exception as e:
248
  print(f"Error: {e}")
249
 
250
-
251
- # bot stuff ---------------------------------------------------------------------------------------------------------------------------------------------------------------
252
-
 
 
 
 
 
 
 
 
 
 
 
 
253
 
254
  @bot.event
255
  async def on_ready():
256
  print('Logged on as', bot.user)
257
- #bot.log_channel = bot.get_channel(1100458786826747945) # bot-test
258
  bot.log_channel = bot.get_channel(1036960509586587689) # admin-logs
259
 
260
 
 
52
  - more alerts for more stuff?
53
 
54
  '''
55
+ # stats stuff ---------------------------------------------------------------------------------------------------------------------------------------------------------
56
  number_of_messages = 0
57
 
58
  @bot.event
 
71
  except Exception as e:
72
  print(f"Error: {e}")
73
 
74
+ # moderation stuff-----------------------------------------------------------------------------------------------------------------------------------------------------
75
+
76
  @bot.event
77
  async def on_message_edit(before, after):
78
  try:
 
126
  except Exception as e:
127
  print(f"Error: {e}")
128
 
129
+ # nickname stuff ---------------------------------------------------------------------------------------------------------------------------
130
  @bot.event
131
  async def on_member_update(before, after):
132
  try:
 
152
  @bot.event
153
  async def on_member_ban(guild, user):
154
  try:
155
+ async for entry in guild.audit_logs(limit=5, action=discord.AuditLogAction.ban):
156
+ if entry.target == user:
157
+
158
+ account_age = datetime.utcnow() - user.created_at
159
+ created_and_age = f"{user.created_at} ({account_age})"
160
+ reason = f"Reason: {entry.reason}" if entry.reason else "No reason provided."
161
+ content = "<@&1108342563628404747>" # @alerts role
162
+
163
+ embed = Embed(color=Color.red())
164
+ embed.set_author(name=f"{user} ID: {user.id}", icon_url=user.avatar.url)
165
+ embed.title = "User Banned"
166
+ embed.add_field(name="User", value=user.mention, inline=True)
167
+ embed.add_field(name="Nickname", value=user.nick, inline=True)
168
+ embed.add_field(name="Account Age", value=created_and_age, inline=True)
169
+ embed.add_field(name="Moderator", value=entry.user.mention, inline=True)
170
+ embed.add_field(name="Nickname", value=entry.user.nick, inline=True)
171
+ embed.add_field(name="Reason", value=reason, inline=False)
172
+ embed.set_footer(text=f"{convert_to_timezone(datetime.utcnow(), zurich_tz)}")
173
+ await bot.test_channel.send(content=content, embed=embed)
174
  """
 
 
 
175
  # member banned from the guild
176
  embed = Embed(description=f'Member {user.mention} was banned from the guild', color=Color.red())
177
  await bot.log_channel.send(embed=embed)
178
+ """
179
+
180
  except Exception as e:
181
+ print(f"Error: {e}")
182
+
183
+ """
184
+ async for entry in before.guild.audit_logs(limit=5):
185
+ print(f'{entry.user} did {entry.action} to {entry.target}') (and add reason if it exists)
186
+ """
187
+
188
 
189
  @bot.event
190
  async def on_member_unban(guild, user):
 
195
  except Exception as e:
196
  print(f"Error: {e}")
197
 
198
+ # admin stuff-----------------------------------------------------------------------------------------------------------------------
 
199
 
200
  @bot.event
201
  async def on_guild_channel_create(channel):
 
269
  except Exception as e:
270
  print(f"Error: {e}")
271
 
272
+ # github test stuff -------------------------------------------------------------------------------------------------------------------
273
+ """
274
+ async def check_github():
275
+ url = f'https://api.github.com/repos/{github_repo}/pulls'
276
+ response = requests.get(url)
277
+ pulls = response.json()
278
+
279
+ for pull in pulls:
280
+ # Check if the pull request was just opened
281
+ if pull['state'] == 'open' and pull['created_at'] == pull['updated_at']:
282
+ channel = client.get_channel(channel_id)
283
+ if channel:
284
+ await channel.send(f'New PR opened: {pull["title"]}')
285
+ """
286
+ # bot stuff ---------------------------------------------------------------------------------------------------------------------------
287
 
288
  @bot.event
289
  async def on_ready():
290
  print('Logged on as', bot.user)
291
+ bot.test_channel = bot.get_channel(1100458786826747945) # bot-test
292
  bot.log_channel = bot.get_channel(1036960509586587689) # admin-logs
293
 
294