#Having problem is using prefixed commands with Cogs

1 messages · Page 1 of 1 (latest)

keen nova
#

discord.errors.ExtensionFailed: Extension 'commands.bills' raised an error: AttributeError: 'Bot' object has no attribute 'add_command'

#

I am using cogs with slash commands and this works perfectly

#

but whenever i want to use prefix with cogs then i have to face difficulties and unexpexted errors

#

i have only this little code

import discord
from discord.ext import commands

class BILLS(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.command()
    async def hello(self, ctx: discord.ApplicationContext):
        await ctx.respond("hello.>!")


def setup(bot):
    bot.add_cog(BILLS(bot))
#

and also in my main.py

bot.load_extension("commands.bills")
remote birch
keen nova
# remote birch In your main file what type of bot are you using?
import discord
from discord.ext import commands
import os
from dotenv import load_dotenv
import sqlite3

intents = discord.Intents.default()
intents.message_content = True

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

# Connect to SQLite database (this will create a new database file if it doesn't exist)
connection = sqlite3.connect("darksinventory.db")
cursor = connection.cursor()


load_dotenv() # load all the variables from the env file
bot = discord.Bot()

@bot.event
async def on_ready():
    print(f"{bot.user} is ready and online!")


bot.load_extension("commands.darkCal")
bot.load_extension("commands.price")
bot.load_extension("commands.bills")


bot.run(os.getenv('BOT_TOKEN'))

#

this is my main file

remote birch
keen nova
#

Umm where bot = discord.Bot()

remote birch
#

bot = commands.Bot() and then
bot = discord.Bot()

keen nova
#

two times

remote birch
#

Yes

#

Remove the discord.Bot line

keen nova
#

when i use command .hello

#

discord.errors.ClientException: Callback for hello command is missing "ctx" parameter.

#

what argument it needs

#

Oh wait wait

#

i forgot self

#

@remote birch Thank you so much for your help

#

😄

#

you can close now

remote birch
#

You have to close it with /close