Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
try accept added, async for entry in bot.guild.audit_logs(limit=5): print(f'{entry.user} did {entry.action} to {entry.target}')
Browse files
app.py
CHANGED
@@ -62,135 +62,179 @@ ping alerts for list of keywords
|
|
62 |
|
63 |
@bot.event
|
64 |
async def on_message_edit(before, after):
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
#embed.set_footer(text=f"{datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S UTC')}")
|
85 |
embed.set_footer(text=f"{convert_to_timezone(datetime.utcnow(), zurich_tz)}")
|
86 |
-
|
87 |
await bot.log_channel.send(embed=embed)
|
88 |
-
|
89 |
-
|
90 |
-
async def on_message_delete(message):
|
91 |
-
if message.author == bot.user:
|
92 |
-
return
|
93 |
-
|
94 |
-
embed = Embed(color=Color.red())
|
95 |
-
embed.set_author(name=f"{message.author} ID: {message.author.id}", icon_url=message.author.avatar.url)
|
96 |
-
embed.title = "Message Deleted"
|
97 |
-
embed.description = message.content or "*(empty message)*"
|
98 |
-
embed.add_field(name="Author Username", value=message.author.name, inline=True)
|
99 |
-
embed.add_field(name="Channel", value=message.channel.mention, inline=True)
|
100 |
-
#embed.add_field(name="Message Created On", value=message.created_at.strftime("%Y-%m-%d %H:%M:%S UTC"), inline=True)
|
101 |
-
embed.add_field(name="Message Created On", value=convert_to_timezone(message.created_at, zurich_tz), inline=True)
|
102 |
-
embed.add_field(name="Message ID", value=message.id, inline=True)
|
103 |
-
embed.add_field(name="Message Jump URL", value=f"[Jump to message!](https://discord.com/channels/{message.guild.id}/{message.channel.id}/{message.id})", inline=True)
|
104 |
-
|
105 |
-
if message.attachments:
|
106 |
-
attachment_urls = "\n".join([attachment.url for attachment in message.attachments])
|
107 |
-
embed.add_field(name="Attachments", value=attachment_urls, inline=False)
|
108 |
-
|
109 |
-
#embed.set_footer(text=f"{datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S UTC')}")
|
110 |
-
embed.set_footer(text=f"{convert_to_timezone(datetime.utcnow(), zurich_tz)}")
|
111 |
-
|
112 |
-
await bot.log_channel.send(embed=embed)
|
113 |
|
114 |
# nickname stuff
|
115 |
@bot.event
|
116 |
async def on_member_update(before, after):
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
|
131 |
@bot.event
|
132 |
async def on_member_ban(guild, user):
|
133 |
-
|
134 |
-
|
135 |
-
|
|
|
|
|
|
|
|
|
136 |
|
137 |
@bot.event
|
138 |
async def on_member_unban(guild, user):
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
|
|
|
|
|
|
|
|
143 |
# admin stuff---------------------------------------------------------------------------------------------------------------------------------------------------------------
|
144 |
|
145 |
@bot.event
|
146 |
async def on_guild_channel_create(channel):
|
147 |
-
|
148 |
-
|
149 |
-
|
|
|
|
|
|
|
150 |
|
|
|
151 |
@bot.event
|
152 |
async def on_guild_channel_delete(channel):
|
153 |
-
|
154 |
-
|
155 |
-
|
|
|
|
|
|
|
156 |
|
|
|
157 |
@bot.event
|
158 |
async def on_guild_role_create(role):
|
159 |
-
|
160 |
-
|
161 |
-
|
|
|
|
|
|
|
162 |
|
|
|
163 |
@bot.event
|
164 |
async def on_guild_role_delete(role):
|
165 |
-
|
166 |
-
|
167 |
-
|
|
|
|
|
|
|
168 |
|
|
|
169 |
@bot.event
|
170 |
async def on_guild_role_update(before, after):
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
|
|
|
|
|
|
|
|
182 |
@bot.event
|
183 |
async def on_voice_state_update(member, before, after):
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
|
|
|
|
|
|
|
|
194 |
# bot stuff ---------------------------------------------------------------------------------------------------------------------------------------------------------------
|
195 |
|
196 |
|
|
|
62 |
|
63 |
@bot.event
|
64 |
async def on_message_edit(before, after):
|
65 |
+
try:
|
66 |
+
if before.author == bot.user:
|
67 |
+
return
|
68 |
+
|
69 |
+
if before.content != after.content:
|
70 |
+
embed = Embed(color=Color.orange())
|
71 |
+
embed.set_author(name=f"{before.author} ID: {before.author.id}", icon_url=before.author.avatar.url)
|
72 |
+
embed.title = "Message Edited"
|
73 |
+
embed.description = f"**Before:** {before.content or '*(empty message)*'}\n**After:** {after.content or '*(empty message)*'}"
|
74 |
+
embed.add_field(name="Author Username", value=before.author.name, inline=True)
|
75 |
+
embed.add_field(name="Channel", value=before.channel.mention, inline=True)
|
76 |
+
#embed.add_field(name="Message Created On", value=before.created_at.strftime("%Y-%m-%d %H:%M:%S UTC"), inline=True)
|
77 |
+
embed.add_field(name="Message Created On", value=convert_to_timezone(before.created_at, zurich_tz), inline=True)
|
78 |
+
embed.add_field(name="Message ID", value=before.id, inline=True)
|
79 |
+
embed.add_field(name="Message Jump URL", value=f"[Jump to message!](https://discord.com/channels/{before.guild.id}/{before.channel.id}/{before.id})", inline=True)
|
80 |
+
|
81 |
+
if before.attachments:
|
82 |
+
attachment_urls = "\n".join([attachment.url for attachment in before.attachments])
|
83 |
+
embed.add_field(name="Attachments", value=attachment_urls, inline=False)
|
84 |
+
|
85 |
+
#embed.set_footer(text=f"{datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S UTC')}")
|
86 |
+
embed.set_footer(text=f"{convert_to_timezone(datetime.utcnow(), zurich_tz)}")
|
87 |
+
|
88 |
+
await bot.log_channel.send(embed=embed)
|
89 |
+
except Exception as e:
|
90 |
+
print(f"Error: {e}")
|
91 |
|
92 |
+
@bot.event
|
93 |
+
async def on_message_delete(message):
|
94 |
+
try:
|
95 |
+
if message.author == bot.user:
|
96 |
+
return
|
97 |
+
|
98 |
+
embed = Embed(color=Color.red())
|
99 |
+
embed.set_author(name=f"{message.author} ID: {message.author.id}", icon_url=message.author.avatar.url)
|
100 |
+
embed.title = "Message Deleted"
|
101 |
+
embed.description = message.content or "*(empty message)*"
|
102 |
+
embed.add_field(name="Author Username", value=message.author.name, inline=True)
|
103 |
+
embed.add_field(name="Channel", value=message.channel.mention, inline=True)
|
104 |
+
#embed.add_field(name="Message Created On", value=message.created_at.strftime("%Y-%m-%d %H:%M:%S UTC"), inline=True)
|
105 |
+
embed.add_field(name="Message Created On", value=convert_to_timezone(message.created_at, zurich_tz), inline=True)
|
106 |
+
embed.add_field(name="Message ID", value=message.id, inline=True)
|
107 |
+
embed.add_field(name="Message Jump URL", value=f"[Jump to message!](https://discord.com/channels/{message.guild.id}/{message.channel.id}/{message.id})", inline=True)
|
108 |
+
|
109 |
+
if message.attachments:
|
110 |
+
attachment_urls = "\n".join([attachment.url for attachment in message.attachments])
|
111 |
+
embed.add_field(name="Attachments", value=attachment_urls, inline=False)
|
112 |
+
|
113 |
#embed.set_footer(text=f"{datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S UTC')}")
|
114 |
embed.set_footer(text=f"{convert_to_timezone(datetime.utcnow(), zurich_tz)}")
|
115 |
+
|
116 |
await bot.log_channel.send(embed=embed)
|
117 |
+
except Exception as e:
|
118 |
+
print(f"Error: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
|
120 |
# nickname stuff
|
121 |
@bot.event
|
122 |
async def on_member_update(before, after):
|
123 |
+
try:
|
124 |
+
if before.name != after.name:
|
125 |
+
print(f"Username changed for {after.mention}: {before.name} -> {after.name}")
|
126 |
+
"""
|
127 |
+
embed = Embed(description=f"Username changed for {after.mention}: {before.name} -> {after.name}", color=Color.blue())
|
128 |
+
await bot.log_channel.send(embed=embed)
|
129 |
+
"""
|
130 |
+
|
131 |
+
if before.nick != after.nick:
|
132 |
+
print(f"Nickname changed for {after.mention}: {before.nick} -> {after.nick}")
|
133 |
+
|
134 |
+
if before.discriminator != after.discriminator:
|
135 |
+
print(f"Discriminator changed for {after.mention}: {before.discriminator} -> {after.discriminator}")
|
136 |
+
|
137 |
+
|
138 |
+
async for entry in bot.guild.audit_logs(limit=5):
|
139 |
+
print(f'{entry.user} did {entry.action} to {entry.target}')
|
140 |
+
except Exception as e:
|
141 |
+
print(f"Error: {e}")
|
142 |
|
143 |
@bot.event
|
144 |
async def on_member_ban(guild, user):
|
145 |
+
try:
|
146 |
+
# member banned from the guild
|
147 |
+
embed = Embed(description=f'Member {user.mention} was banned from the guild', color=Color.red())
|
148 |
+
await bot.log_channel.send(embed=embed)
|
149 |
+
except Exception as e:
|
150 |
+
print(f"Error: {e}")
|
151 |
+
|
152 |
|
153 |
@bot.event
|
154 |
async def on_member_unban(guild, user):
|
155 |
+
try:
|
156 |
+
# member unbanned from the guild
|
157 |
+
embed = Embed(description=f'Member {user.mention} was unbanned from the guild', color=Color.green())
|
158 |
+
await bot.log_channel.send(embed=embed)
|
159 |
+
except Exception as e:
|
160 |
+
print(f"Error: {e}")
|
161 |
+
|
162 |
+
|
163 |
# admin stuff---------------------------------------------------------------------------------------------------------------------------------------------------------------
|
164 |
|
165 |
@bot.event
|
166 |
async def on_guild_channel_create(channel):
|
167 |
+
try:
|
168 |
+
# creating channels
|
169 |
+
embed = Embed(description=f'Channel {channel.mention} was created', color=Color.green())
|
170 |
+
await bot.log_channel.send(embed=embed)
|
171 |
+
except Exception as e:
|
172 |
+
print(f"Error: {e}")
|
173 |
|
174 |
+
|
175 |
@bot.event
|
176 |
async def on_guild_channel_delete(channel):
|
177 |
+
try:
|
178 |
+
# deleting channels, should ping @alerts for this
|
179 |
+
embed = Embed(description=f'Channel {channel.name} ({channel.mention}) was deleted', color=Color.red())
|
180 |
+
await bot.log_channel.send(embed=embed)
|
181 |
+
except Exception as e:
|
182 |
+
print(f"Error: {e}")
|
183 |
|
184 |
+
|
185 |
@bot.event
|
186 |
async def on_guild_role_create(role):
|
187 |
+
try:
|
188 |
+
# creating roles
|
189 |
+
embed = Embed(description=f'Role {role.mention} was created', color=Color.green())
|
190 |
+
await bot.log_channel.send(embed=embed)
|
191 |
+
except Exception as e:
|
192 |
+
print(f"Error: {e}")
|
193 |
|
194 |
+
|
195 |
@bot.event
|
196 |
async def on_guild_role_delete(role):
|
197 |
+
try:
|
198 |
+
# deleting roles, should ping @alerts for this
|
199 |
+
embed = Embed(description=f'Role {role.name} ({role.mention}) was deleted', color=Color.red())
|
200 |
+
await bot.log_channel.send(embed=embed)
|
201 |
+
except Exception as e:
|
202 |
+
print(f"Error: {e}")
|
203 |
|
204 |
+
|
205 |
@bot.event
|
206 |
async def on_guild_role_update(before, after):
|
207 |
+
try:
|
208 |
+
# editing roles, could expand this
|
209 |
+
if before.name != after.name:
|
210 |
+
embed = Embed(description=f'Role {before.mention} was renamed to {after.name}', color=Color.orange())
|
211 |
+
await bot.log_channel.send(embed=embed)
|
212 |
+
|
213 |
+
if before.permissions.administrator != after.permissions.administrator:
|
214 |
+
# changes involving the administrator permission / sensitive permissions (can help to prevent mistakes)
|
215 |
+
content = "<@&1108342563628404747>" # @alerts role
|
216 |
+
embed = Embed(description=f'Role {after.mention} had its administrator permission {"enabled" if after.permissions.administrator else "disabled"}', color=Color.red())
|
217 |
+
await bot.log_channel.send(content=content, embed=embed)
|
218 |
+
except Exception as e:
|
219 |
+
print(f"Error: {e}")
|
220 |
+
|
221 |
+
|
222 |
@bot.event
|
223 |
async def on_voice_state_update(member, before, after):
|
224 |
+
try:
|
225 |
+
if before.mute != after.mute:
|
226 |
+
# muting members
|
227 |
+
embed = Embed(description=f'{member} was {"muted" if after.mute else "unmuted"} in voice chat', color=Color.orange())
|
228 |
+
await bot.log_channel.send(embed=embed)
|
229 |
+
|
230 |
+
if before.deaf != after.deaf:
|
231 |
+
# deafening members
|
232 |
+
embed = Embed(description=f'{member} was {"deafened" if after.deaf else "undeafened"} in voice chat', color=Color.orange())
|
233 |
+
await bot.log_channel.send(embed=embed)
|
234 |
+
except Exception as e:
|
235 |
+
print(f"Error: {e}")
|
236 |
+
|
237 |
+
|
238 |
# bot stuff ---------------------------------------------------------------------------------------------------------------------------------------------------------------
|
239 |
|
240 |
|