#Having problem is using prefixed commands with Cogs
1 messages · Page 1 of 1 (latest)
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")
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
Do you realise you're overwriting your bot instance?
Umm where bot = discord.Bot()
bot = commands.Bot() and then
bot = discord.Bot()
two times
i did it
and now the code it running
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
You have to close it with /close