This repository was archived by the owner on Apr 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
81 lines (61 loc) · 2.87 KB
/
bot.py
File metadata and controls
81 lines (61 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import discord
from discord.ext import commands
intents = discord.Intents.all()
bot = commands.Bot(command_prefix='!', intents=intents)
@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name} ({bot.user.id})')
print('------')
@bot.event
async def on_member_remove(member):
mod_log_channel_id = 12127419833285
if member.guild.me.guild_permissions.view_audit_log:
async for entry in member.guild.audit_logs(limit=1, action=discord.AuditLogAction.kick):
if entry.target == member:
log_message = f"{member.display_name} has been kicked by {entry.user.display_name}"
break
else:
log_message = f"{member.display_name} left the server (could not retrieve audit log)."
mod_log_channel = bot.get_channel(mod_log_channel_id)
await mod_log_channel.send(log_message)
@bot.event
async def on_member_ban(guild, user):
mod_log_channel_id = 12127419833285
if guild.me.guild_permissions.view_audit_log:
async for entry in guild.audit_logs(limit=1, action=discord.AuditLogAction.ban):
if entry.target == user:
log_message = f"{user.display_name} has been banned by {entry.user.display_name}"
break
else:
log_message = f"{user.display_name} has been banned (could not retrieve audit log)."
mod_log_channel = bot.get_channel(mod_log_channel_id)
await mod_log_channel.send(log_message)
@bot.event
async def on_member_unban(guild, user):
mod_log_channel_id = 12127419833285
if guild.me.guild_permissions.view_audit_log:
async for entry in guild.audit_logs(limit=1, action=discord.AuditLogAction.unban):
if entry.target == user:
log_message = f"{user.display_name} has been unbanned by {entry.user.display_name}"
break
else:
log_message = f"{user.display_name} has been unbanned (could not retrieve audit log)."
mod_log_channel = bot.get_channel(mod_log_channel_id)
await mod_log_channel.send(log_message)
@bot.event
async def on_member_update(before, after):
mod_log_channel_id = 12127419833285
if not before.guild.me.guild_permissions.view_audit_log:
return
async for entry in before.guild.audit_logs(limit=1, action=discord.AuditLogAction.member_update):
if entry.target == before and before.roles != after.roles:
if len(before.roles) > len(after.roles):
log_message = f"{before.display_name} has been muted by {entry.user.display_name}"
elif len(before.roles) < len(after.roles):
log_message = f"{before.display_name} has been unmuted by {entry.user.display_name}"
else:
return
mod_log_channel = bot.get_channel(mod_log_channel_id)
await mod_log_channel.send(log_message)
break
bot.run('Place Your Token Here')