-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
72 lines (58 loc) · 2.47 KB
/
main.py
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
import nextcord
import os
import json
from nextcord.ext import commands
#import token from file
from apikeys import TOKEN
from settings import logs_channel
intents = nextcord.Intents.all()
def save_event(**event):
print(event)
client = commands.Bot(command_prefix='.', intents=intents) #define prefix
@client.event
async def on_ready():
await client.change_presence(activity=nextcord.Game("It's a bot what did you expect?"))
@client.command() #define commands
async def hello(ctx):
await ctx.send("Hello, I'm still working!")
############################################
#Learning Cogs
extensions = []
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
extensions.append("cogs." + filename[:-3])#to delete .py
if __name__== '__main__':
for extension in extensions:
client.load_extension(extension)
@client.command()
async def reload(ctx):
await ctx.message.delete()
extensions = []
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
extensions.append("cogs." + filename[:-3])#to delete .py
if __name__== '__main__':
for extension in extensions:
client.unload_extension(extension)
if __name__== '__main__':
for extension in extensions:
client.load_extension(extension)
await ctx.send(f'{extension} reloaded',delete_after=5)
@client.event
async def on_message_delete(message):
async for entry in message.guild.audit_logs(limit=1,action=nextcord.AuditLogAction.message_delete):
deleter = entry.user
if deleter != message.author.name:
embed = nextcord.Embed(title=f"{deleter.name} usunął wiadomość {message.author.name} z kanału {message.channel}",description=f"{message.content}")
else:
embed = nextcord.Embed(title=f"{message.author.name} usunął wiadomość {message.author.name} z kanału {message.channel}",description=f"{message.content}")
channel = client.get_channel(logs_channel)
await channel.send(embed=embed)
@client.event
async def on_message_edit(message_before,message_after):
embed_message = nextcord.Embed(title=f"{message_before.author.name} edytował wiadomość na kanale {message_before.channel}")
embed_message.add_field(name="Przed",value=f"{message_before.content}",inline=False)
embed_message.add_field(name="Po",value=f"{message_after.content}",inline=False)
channel = client.get_channel(logs_channel)
await channel.send(embed=embed_message)
client.run(TOKEN)