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 ( |
Answered by
Dorukyum
Oct 4, 2021
Replies: 2 comments 2 replies
|
We are currently working on subcommands in cogs, so they arent ready to use yet. |
2 replies
Answer selected by
Lulalaby
|
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 |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.