Hi guys, how do you add a class containing commands into a bot inheriting from commands.Bot? For example
class MyBotCog(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.command(name='roll')
async def roll(self, ctx: commands.Context):
print("rolling...")
random_number = str(random.randint(1, 6))
await ctx.send(random_number)
when I try to add it into the MyBot class
class MyBot(commands.Bot):
def __init__(self, command_prefix, intents):
super().__init__(command_prefix, intents=intents)
self.add_cog(MyBotCog(self)) # <--- This line
# Rest of implementation ...
and run the bot with the commnd prefix !, I get:
discord.ext.commands.errors.CommandNotFound: Command "roll" is not found
when I run !roll on Discord
Thanks for the help!