class Stats(discord.Cog):
def __init__(self, bot):
self.bot = bot
stats = SlashCommandGroup("stats", "Retreive stats about a user or a match.")
@stats.command(name="username", description="Retrieve stats of a user by username.")
async def username(self, context, username: str) -> None:
await context.defer()
await context.respond('test')
@stats.command(name="usertest", description="Bruh")
async def usertest(self, context, username: discord.Option(discord.SlashCommandOptionType.user)) -> None:
await context.defer()
await context.respond("Bruh")
@stats.command(name="bruhtest", description="Bruh")
async def bruhtest(self, context, username: discord.Option(discord.SlashCommandOptionType.user)):
await context.defer()
await context.respond("Bruh")
#Cog with slash command group only works when I have one command in the group.
1 messages · Page 1 of 1 (latest)
When I have the two stats.commands usertest and bruh test it, it does this
DEBUG:discord.bot: Bulk updating commands {'stats': 'delete'} for guild 1003529640557690981
then if i remove them it re adds the command
2022-08-22 07:39:51,671:DEBUG:discord.bot: Bulk updating commands {'stats': 'upsert'} for guild 1003529640557690981
how are you loading the ext/adding the cog
add store=False to load_extension
I did that, and ran it after and it still removes the commands from the server
didn't raise an error?
Failed to load extension info.
Cog, stats, has loaded.
I'd fix the error with info and see if that solves it
Failed to load extension stats. Extension 'cogs.stats' raised an error: TypeError: issubclass() arg 1 must be a class
I got rid of the info cog
import discord, asyncio
from discord.commands import SlashCommandGroup
class Stats(discord.Cog):
def __init__(self, bot):
self.bot = bot
stats = SlashCommandGroup("stats", "Retreive stats about a user or a match.")
@stats.command(name="username", description="Retrieve stats of a user by username.")
async def username(self, context, username: str) -> None:
await context.defer()
await context.respond('test')
@stats.command(name="usertest", description="Bruh")
async def usertest(self, context, username: discord.Option(discord.SlashCommandOptionType.user)) -> None:
await context.defer()
await context.respond("Bruh")
@stats.command(name="bruhtest", description="Bruh")
async def bruhtest(self, context, username: discord.Option(discord.SlashCommandOptionType.user)) -> None:
await context.defer()
await context.respond("Bruh")
def setup(bot):
bot.add_cog(Stats(bot))
Of pycord?
yes
deadass?
SlashCommandOptionType is only used internally
i swear if this is in one of the examples i'm gonna cry
you can still pass it to discord.Option though
eventually use commands.Cog and not discord
it is
yeah but why
pl
okok
wait
so now its this
import discord, asyncio
from discord.commands import SlashCommandGroup
class Stats(discord.Cog):
def __init__(self, bot):
self.bot = bot
stats = SlashCommandGroup("stats", "Retreive stats about a user or a match.")
@stats.command(name="username", description="Retrieve stats of a user by username.")
async def username(self, context, username: str) -> None:
await context.defer()
await context.respond('test')
@stats.command(name="usertest", description="Bruh")
async def usertest(self, context, username: discord.user) -> None:
await context.defer()
await context.respond("Bruh")
@stats.command(name="bruhtest", description="Bruh")
async def bruhtest(self, context, username: discord.user) -> None:
await context.defer()
await context.respond("Bruh")
def setup(bot):
bot.add_cog(Stats(bot))
and im still getting
Failed to load extension stats. Extension 'cogs.stats' raised an error: TypeError: issubclass() arg 1 must be a class
sigh
it was User
im updating examples
notuser
yes
pretty sure it was in one of the examples
uhh
Learn all about Slash Commands and how to implement them into your Discord Bot with Pycord!
oh guide
i hate the typehinting syntax that we support
i've always found name: discord.Option(type, ...) to work perfectly
while decorators have gone through hell and back
and i think name: type = discord.Option(...) also broke
maybe we should just be less lenient lol
we only had to go through hell and back to make it with with from __future__ import annotations

yeah but people always reported bugs with it
like i remember one beta version half the threads were because of decorators
I feel like I'm the only one who uses non-typehinting syntax
do you just do discord.Option then? interesting
Yo yall must be speaking some ancient moon language
one day
it's actually better because then I can typehint the parameter properly instead of my IDE saying it's supposed to be an Option class
I NEED to retake a python course
