Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
LOG_CHANNEL
Browse files
app.py
CHANGED
@@ -21,7 +21,7 @@ import asyncio # check if used
|
|
21 |
|
22 |
zurich_tz = timezone("Europe/Zurich")
|
23 |
bot = commands.Bot(command_prefix='!', intents=discord.Intents.all())
|
24 |
-
|
25 |
|
26 |
def convert_to_timezone(dt, tz):
|
27 |
return dt.astimezone(tz).strftime("%Y-%m-%d %H:%M:%S %Z")
|
@@ -70,7 +70,7 @@ async def on_message_edit(before, after):
|
|
70 |
#embed.set_footer(text=f"{datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S UTC')}")
|
71 |
embed.set_footer(text=f"{convert_to_timezone(datetime.utcnow(), zurich_tz)}")
|
72 |
|
73 |
-
await
|
74 |
|
75 |
@bot.event
|
76 |
async def on_message_delete(message):
|
@@ -95,26 +95,26 @@ async def on_message_delete(message):
|
|
95 |
#embed.set_footer(text=f"{datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S UTC')}")
|
96 |
embed.set_footer(text=f"{convert_to_timezone(datetime.utcnow(), zurich_tz)}")
|
97 |
|
98 |
-
await
|
99 |
|
100 |
# nickname stuff
|
101 |
@bot.event
|
102 |
async def on_member_update(before, after):
|
103 |
if before.nick != after.nick:
|
104 |
embed = Embed(description=f'{before} changed their nickname to {after.nick}', color=Color.blue())
|
105 |
-
await
|
106 |
|
107 |
@bot.event
|
108 |
async def on_member_ban(guild, user):
|
109 |
# member banned from the guild
|
110 |
embed = Embed(description=f'Member {user.mention} was banned from the guild', color=Color.red())
|
111 |
-
await
|
112 |
|
113 |
@bot.event
|
114 |
async def on_member_unban(guild, user):
|
115 |
# member unbanned from the guild
|
116 |
embed = Embed(description=f'Member {user.mention} was unbanned from the guild', color=Color.green())
|
117 |
-
await
|
118 |
|
119 |
# admin stuff---------------------------------------------------------------------------------------------------------------------------------------------------------------
|
120 |
|
@@ -122,51 +122,51 @@ async def on_member_unban(guild, user):
|
|
122 |
async def on_guild_channel_create(channel):
|
123 |
# creating channels
|
124 |
embed = Embed(description=f'Channel {channel.mention} was created', color=Color.green())
|
125 |
-
await
|
126 |
|
127 |
@bot.event
|
128 |
async def on_guild_channel_delete(channel):
|
129 |
# deleting channels, should ping @alerts for this
|
130 |
embed = Embed(description=f'Channel {channel.name} ({channel.mention}) was deleted', color=Color.red())
|
131 |
-
await
|
132 |
|
133 |
@bot.event
|
134 |
async def on_guild_role_create(role):
|
135 |
# creating roles
|
136 |
embed = Embed(description=f'Role {role.mention} was created', color=Color.green())
|
137 |
-
await
|
138 |
|
139 |
@bot.event
|
140 |
async def on_guild_role_delete(role):
|
141 |
# deleting roles, should ping @alerts for this
|
142 |
embed = Embed(description=f'Role {role.name} ({role.mention}) was deleted', color=Color.red())
|
143 |
-
await
|
144 |
|
145 |
@bot.event
|
146 |
async def on_guild_role_update(before, after):
|
147 |
# editing roles, could expand this
|
148 |
if before.name != after.name:
|
149 |
embed = Embed(description=f'Role {before.mention} was renamed to {after.name}', color=Color.orange())
|
150 |
-
await
|
151 |
|
152 |
if before.permissions.administrator != after.permissions.administrator:
|
153 |
# changes involving the administrator permission / sensitive permissions (can help to prevent mistakes)
|
154 |
certain_role_id = 1106995261487710411 # role to ping (@alerts)
|
155 |
certain_role = after.guild.get_role(certain_role_id)
|
156 |
embed = Embed(description=f'Role {after.mention} had its administrator permission {"enabled" if after.permissions.administrator else "disabled"}', color=Color.red())
|
157 |
-
await
|
158 |
|
159 |
@bot.event
|
160 |
async def on_voice_state_update(member, before, after):
|
161 |
if before.mute != after.mute:
|
162 |
# muting members
|
163 |
embed = Embed(description=f'{member} was {"muted" if after.mute else "unmuted"} in voice chat', color=Color.orange())
|
164 |
-
await
|
165 |
|
166 |
if before.deaf != after.deaf:
|
167 |
# deafening members
|
168 |
embed = Embed(description=f'{member} was {"deafened" if after.deaf else "undeafened"} in voice chat', color=Color.orange())
|
169 |
-
await
|
170 |
|
171 |
# bot stuff ---------------------------------------------------------------------------------------------------------------------------------------------------------------
|
172 |
|
@@ -177,9 +177,7 @@ DISCORD_TOKEN = os.environ.get("DISCORD_TOKEN", None)
|
|
177 |
@bot.event
|
178 |
async def on_ready():
|
179 |
print('Logged on as', bot.user)
|
180 |
-
bot.log_channel = bot.get_channel(1100458786826747945)
|
181 |
|
182 |
-
|
183 |
|
184 |
def run_bot():
|
185 |
bot.run(DISCORD_TOKEN)
|
|
|
21 |
|
22 |
zurich_tz = timezone("Europe/Zurich")
|
23 |
bot = commands.Bot(command_prefix='!', intents=discord.Intents.all())
|
24 |
+
LOG_CHANNEL = bot.get_channel(1100458786826747945)
|
25 |
|
26 |
def convert_to_timezone(dt, tz):
|
27 |
return dt.astimezone(tz).strftime("%Y-%m-%d %H:%M:%S %Z")
|
|
|
70 |
#embed.set_footer(text=f"{datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S UTC')}")
|
71 |
embed.set_footer(text=f"{convert_to_timezone(datetime.utcnow(), zurich_tz)}")
|
72 |
|
73 |
+
await LOG_CHANNEL.send(embed=embed)
|
74 |
|
75 |
@bot.event
|
76 |
async def on_message_delete(message):
|
|
|
95 |
#embed.set_footer(text=f"{datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S UTC')}")
|
96 |
embed.set_footer(text=f"{convert_to_timezone(datetime.utcnow(), zurich_tz)}")
|
97 |
|
98 |
+
await LOG_CHANNEL.send(embed=embed)
|
99 |
|
100 |
# nickname stuff
|
101 |
@bot.event
|
102 |
async def on_member_update(before, after):
|
103 |
if before.nick != after.nick:
|
104 |
embed = Embed(description=f'{before} changed their nickname to {after.nick}', color=Color.blue())
|
105 |
+
await LOG_CHANNEL.send(embed=embed)
|
106 |
|
107 |
@bot.event
|
108 |
async def on_member_ban(guild, user):
|
109 |
# member banned from the guild
|
110 |
embed = Embed(description=f'Member {user.mention} was banned from the guild', color=Color.red())
|
111 |
+
await LOG_CHANNEL.send(embed=embed)
|
112 |
|
113 |
@bot.event
|
114 |
async def on_member_unban(guild, user):
|
115 |
# member unbanned from the guild
|
116 |
embed = Embed(description=f'Member {user.mention} was unbanned from the guild', color=Color.green())
|
117 |
+
await LOG_CHANNEL.send(embed=embed)
|
118 |
|
119 |
# admin stuff---------------------------------------------------------------------------------------------------------------------------------------------------------------
|
120 |
|
|
|
122 |
async def on_guild_channel_create(channel):
|
123 |
# creating channels
|
124 |
embed = Embed(description=f'Channel {channel.mention} was created', color=Color.green())
|
125 |
+
await LOG_CHANNEL.send(embed=embed)
|
126 |
|
127 |
@bot.event
|
128 |
async def on_guild_channel_delete(channel):
|
129 |
# deleting channels, should ping @alerts for this
|
130 |
embed = Embed(description=f'Channel {channel.name} ({channel.mention}) was deleted', color=Color.red())
|
131 |
+
await LOG_CHANNEL.send(embed=embed)
|
132 |
|
133 |
@bot.event
|
134 |
async def on_guild_role_create(role):
|
135 |
# creating roles
|
136 |
embed = Embed(description=f'Role {role.mention} was created', color=Color.green())
|
137 |
+
await LOG_CHANNEL.send(embed=embed)
|
138 |
|
139 |
@bot.event
|
140 |
async def on_guild_role_delete(role):
|
141 |
# deleting roles, should ping @alerts for this
|
142 |
embed = Embed(description=f'Role {role.name} ({role.mention}) was deleted', color=Color.red())
|
143 |
+
await LOG_CHANNEL.send(embed=embed)
|
144 |
|
145 |
@bot.event
|
146 |
async def on_guild_role_update(before, after):
|
147 |
# editing roles, could expand this
|
148 |
if before.name != after.name:
|
149 |
embed = Embed(description=f'Role {before.mention} was renamed to {after.name}', color=Color.orange())
|
150 |
+
await LOG_CHANNEL.send(embed=embed)
|
151 |
|
152 |
if before.permissions.administrator != after.permissions.administrator:
|
153 |
# changes involving the administrator permission / sensitive permissions (can help to prevent mistakes)
|
154 |
certain_role_id = 1106995261487710411 # role to ping (@alerts)
|
155 |
certain_role = after.guild.get_role(certain_role_id)
|
156 |
embed = Embed(description=f'Role {after.mention} had its administrator permission {"enabled" if after.permissions.administrator else "disabled"}', color=Color.red())
|
157 |
+
await LOG_CHANNEL.send(content=certain_role.mention, embed=embed)
|
158 |
|
159 |
@bot.event
|
160 |
async def on_voice_state_update(member, before, after):
|
161 |
if before.mute != after.mute:
|
162 |
# muting members
|
163 |
embed = Embed(description=f'{member} was {"muted" if after.mute else "unmuted"} in voice chat', color=Color.orange())
|
164 |
+
await LOG_CHANNEL.send(embed=embed)
|
165 |
|
166 |
if before.deaf != after.deaf:
|
167 |
# deafening members
|
168 |
embed = Embed(description=f'{member} was {"deafened" if after.deaf else "undeafened"} in voice chat', color=Color.orange())
|
169 |
+
await LOG_CHANNEL.send(embed=embed)
|
170 |
|
171 |
# bot stuff ---------------------------------------------------------------------------------------------------------------------------------------------------------------
|
172 |
|
|
|
177 |
@bot.event
|
178 |
async def on_ready():
|
179 |
print('Logged on as', bot.user)
|
|
|
180 |
|
|
|
181 |
|
182 |
def run_bot():
|
183 |
bot.run(DISCORD_TOKEN)
|