Event cogs

This commit is contained in:
= 2025-04-06 12:24:56 +07:00
parent 053bf8b5fe
commit 71049a6670
4 changed files with 50 additions and 46 deletions

View File

@ -1,7 +1,7 @@
import nextcord
from nextcord.ext import commands
class Main():
class Main(commands.Cog):
def __init__(self, bot):
self.client = bot

33
events/log.py Normal file
View File

@ -0,0 +1,33 @@
import nextcord
from nextcord.ext import commands
class Main(commands.Cog):
def __init__(self, bot):
self.client = bot
@commands.Cog.listener
async def on_message_delete(self, msg: nextcord.Message):
embed = nextcord.Embed(
title="Message delete",
description=msg.content
)
embed.set_author(name=msg.author.name)
for image in msg.attachments:
embed.set_image(image.url) # Unfortunately i cant add multiple images.
await SquogMod.send(embed=embed)
@commands.Cog.listener
async def on_command(self, ctx: commands.Context):
embed = nextcord.Embed(
title="Command used",
description=ctx.message.content
)
field = embed.add_field(name="Channel", value=ctx.channel.name)
await SquogMod.send(embed=embed)
@commands.Cog.listener
async def on_ready(self):
global SquogMod
print("Bot logged")
SquogMod = self.client.get_channel(1356577069068324986)
print(SquogMod)

16
events/member.py Normal file
View File

@ -0,0 +1,16 @@
import nextcord
from nextcord.ext import commands
class Main(commands.Cog):
def __init__(self, bot):
self.client = bot
@commands.Cog.listener
async def on_member_join(member: nextcord.Member):
print(f"Member {member.display_name} joined")
if member.guild.id == 1356433463854497944: # Only for the squog server
await member.add_roles(nextcord.utils.get(member.guild.roles, name="Squog"))
@commands.Cog.listener
async def on_member_remove(member: nextcord.Member):
print(f"Member {member.display_name} left")

45
main.py
View File

@ -15,51 +15,6 @@ for filename in os.listdir('./commands'):
print(filename)
client.load_extension(f'commands.{filename[:-3]}')
# ______ _
# | ____| | |
# | |____ _____ _ __ | |_ ___
# | __\ \ / / _ | '_ \| __/ __|
# | |___\ V | __| | | | |_\__ \
# |______\_/ \___|_| |_|\__|___/
@client.event
async def on_member_join(member: nextcord.Member):
print(f"Member {member.display_name} joined")
if member.guild.id == 1356433463854497944: # Only for the squog server
await member.add_roles(nextcord.utils.get(member.guild.roles, name="Squog"))
@client.event
async def on_member_remove(member: nextcord.Member):
print(f"Member {member.display_name} left")
@client.event
async def on_message_delete(msg: nextcord.Message):
embed = nextcord.Embed(
title = "Message delete",
description = msg.content
)
embed.set_author(name = msg.author.name)
for image in msg.attachments:
embed.set_image(image.url) # Unfortunately i cant add multiple images.
await SquogMod.send(embed=embed)
@client.event
async def on_command(ctx: commands.Context):
embed = nextcord.Embed(
title="Command used",
description=ctx.message.content
)
field = embed.add_field(name="Channel", value = ctx.channel.name)
await SquogMod.send(embed=embed)
@client.event
async def on_ready():
global SquogMod
print("Bot logged")
SquogMod = client.get_channel(1356577069068324986)
print(SquogMod)
# ______ _ _
# | ____| | | (_)
# | |__ __ _____ ___ _ _| |_ _ _ __ __ _