Требуется перенести все три события: on_ready, on_member_join, on_member_remove в cogs/events.py так чтобы потом в bot.py можно было их активировать.
bot.py
import os
import json
from disnake import Intents, Client
with open("configs/config.json") as f:
config = json.load(f)
GUILD_ID = config["guild_id"]
TOKEN = config["token"]
CHANNEL_ID = config["channel_id"]
intents = Intents.default()
intents.members = True
client = Client(intents=intents)
@client.event
async def on_ready():
print(f"We have logged in as {client.user}")
@client.event
async def on_member_join(member):
channel = client.get_channel(CHANNEL_ID)
if channel:
await channel.send(f"{member.name} joined the server.")
@client.event
async def on_member_remove(member):
channel = client.get_channel(CHANNEL_ID)
if channel:
await channel.send(f"{member.name} left the server.")
client.run(TOKEN)