-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
62 lines (52 loc) · 3.13 KB
/
main.py
File metadata and controls
62 lines (52 loc) · 3.13 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
import discord
from discord.ext import commands
from discord_slash import SlashCommand
from discord_slash.utils.manage_commands import create_option
client = commands.Bot(command_prefix='%')
slash = SlashCommand(client, sync_commands=True)
@client.event
async def on_ready():
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="members for wrongdoing. "))
@client.event
async def on_message(message):
message_logs_channel = discord.utils.get(message.guild.channels, name='message-logs')
if not message.author.bot:
if message_logs_channel:
message.content = message.content.replace('@', '@\u200b')
log_message = f"**{message.author}** sent a message in **{message.channel}**: \n{message.content}"
await message_logs_channel.send(log_message)
else:
print(f"Error: message_logs_channel could not be found")
await client.process_commands(message)
@client.event
async def on_message_edit(before, after):
if before.content != after.content:
before.content = before.content.replace('@', '@\u200b')
after.content = after.content.replace('@', '@\u200b')
log_message = f"**{before.author}** edited a message in **{before.channel}**: \nBefore: {before.content}\nAfter: {after.content}"
await discord.utils.get(before.guild.channels, name='edit-logs').send(log_message)
@client.event
async def on_message_delete(message):
message.content = message.content.replace('@', '@\u200b')
log_message = f"**{message.author}** deleted a message in **{message.channel}**: {message.content}"
await discord.utils.get(message.guild.channels, name='delete-logs').send(log_message)
@slash.slash(name='delete', description='Clear the chat', options=[create_option(name='amount', description='The number of messages to delete', option_type=4, required=False)])
@commands.has_permissions(administrator=True)
async def _clear(ctx, amount=5):
await ctx.channel.purge(limit=amount)
clearmsg = f"**{ctx.author}** cleared **{amount}** messages in **{ctx.channel}**."
await ctx.reply(clearmsg)
@slash.slash(name='kick', description='Kick a member', options=[create_option(name='member', description='The member to kick', option_type=6, required=True), create_option(name='reason', description='The reason for kicking the member', option_type=3, required=False)])
@commands.has_permissions(administrator=True)
async def _kick(ctx, member: discord.Member, reason=None):
await member.kick(reason=reason)
await ctx.reply(f'{member} has been kicked.')
@slash.slash(name='ban', description='Ban a member', options=[create_option(name='member', description='The member to ban', option_type=6, required=True), create_option(name='reason', description='The reason for banning the member', option_type=3, required=False)])
@commands.has_permissions(administrator=True)
async def _ban(ctx, member: discord.Member, reason=None):
await member.ban(reason=reason)
await ctx.reply(f'{member} has been banned.')
@client.event
async def on_slash_command_error(ctx, error):
await ctx.send(f'An error occurred: {str(error)}')
client.run('token lol')