why does my code not send a message when i create channel
Main:
import asyncio
import os
import discord
from discord.ext import commands
intents = discord.Intents.all()
intents.members = True
client = commands.Bot(command_prefix="!", intents=intents, help_command=None)
my_secret = os.environ['Token']
@client.event
async def on_ready():
print("\n\nBot is up!\n\n")
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
client.load_extension(f"cogs.{filename[:-3]}")
my_secret = os.environ['Token']
client.run(my_secret)```
Cog:
```py
import discord
from discord.ext import commands
class MyCog(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_guild_channel_create(self, channel):
"""Event triggered when a new channel is created."""
if channel.guild.system_channel: # Check if the guild has a system channel
await channel.guild.system_channel.send("Hello, world!") # Send a message to the system channel
def setup(client):
client.add_cog(MyCog(client))