NETHUNTER HELPER
NETHUNTER HELPER

Reputation: 11

Cogs Not Working In Discord.py And commands also not working

I've created a discord bot using python but cogs are not working in my bot Please Tell Me Is There Any Mistake in this code

import discord

from discord.ext import commands

import os

from help_cog import help_cog

from music_cog import music_cog

intents = discord.Intents.default()

intents.message_content = True

bot = commands.Bot(command_prefix='=', intents=intents)

bot.remove_command("help")

async def load_extensions():

    await bot.load_extension("help_cog.py")

    await bot.load_extension("music_cog.py")

bot.run('Token')

This is my first file bot.py 👆

import discord

from discord.ext import commands

class help_cog(commands.Cog):

    def __init__(self, bot):

        self.bot = bot

        self.help_message = """

General Commands:

=help - Displays All Avilable Commands

=p - Finds The Song On Youtube And Plays It In Your Current Channel

=q - Shows The Music Queue

=skip - Skips The Currently Playing Song

=clear - Stops The Music And Clear The Queue

=leave - Disconnect The Bot From Voice Channel

=pause - Pauses The Currently Playing Song

=resume - Resumes The Currently Paused Song


"""

        self.text_channel_text = []

        

    @commands.Cog.listener()

    async def on_ready(self):

        for guild in self.bot.guilds:

            for channel in guild.text_channels:

                self.text_channel_text.append(channel)

        

        await self.send_to_all(self.help_message)

        

    async def send_to_all(self, msg):

        for text_channel in self.text_channel_text:

            await text_channel.send(msg)

            

    @commands.command(name='help', help="Displays All Avilable Commands")

    async def help(self, ctx):

        await ctx.send(self.help_message)

            

        

async def setup(bot):

    await bot.add_cog(help_cog(bot))

This is my cog file help_cog.py 👆

There is no output, but it also Doesn't print that bot is ready or something

Upvotes: 1

Views: 449

Answers (1)

stijndcl
stijndcl

Reputation: 5651

You're never calling that load_extensions function, so you're not loading your cogs. It's good that you made it, but you aren't using it.

Discord.py can't smell that it's supposed to call that function, nor that it's supposed to load your cog...

Upvotes: 1

Related Questions