How to make sub slash command in cogs #251
-
Hi, I try to make sub slash commands in cogs with this code: from os import name
from discord.app import slash_command, Option
from discord.app import SlashCommandGroup
from googletrans import Translator
from discord.ext import commands
import discord
from Function import *
translator = Translator()
class Config(commands.Cog):
def __init__(self, bot):
self.bot = bot
math = commands.Bot.command_group(name="math", description="Commands related to mathematics.")
@math.command()
async def add(ctx, num1: int, num2: int):
"""Get the sum of 2 integers."""
await ctx.respond(f"The sum of these numbers is **{num1+num2}**")
def setup(bot):
math = SlashCommandGroup(name="math", description="Commands related to mathematics.")
bot.add_cog(Config(bot)) But I can't set math ( |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
We are currently working on subcommands in cogs, so they arent ready to use yet. |
Beta Was this translation helpful? Give feedback.
-
For anyone stumbling onto this discussion from google, this has now been implemented. c.f. https://github.com/Pycord-Development/pycord/blob/master/examples/app_commands/slash_cog_groups.py |
Beta Was this translation helpful? Give feedback.
We are currently working on subcommands in cogs, so they arent ready to use yet.
Also your usage would be wrong anyway. I suggest learning about Object Oriented Programming with Python before making a Discord bot.