Skip to content

Commit

Permalink
Add module to SlashCommandGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
plun1331 committed Jan 28, 2022
1 parent 0770d11 commit 19f9e45
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 2 deletions.
7 changes: 5 additions & 2 deletions discord/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import re
import types
from collections import OrderedDict
from typing_extensions import ParamSpec, Concatenate
from typing import (
Any,
Callable,
Expand Down Expand Up @@ -77,7 +76,7 @@
)

if TYPE_CHECKING:
from typing_extensions import ParamSpec
from typing_extensions import ParamSpec, Concatenate

from ..cog import Cog

Expand Down Expand Up @@ -922,6 +921,10 @@ def __init__(
if self.permissions and self.default_permission:
self.default_permission = False

@property
def module(self) -> Optional[str]:
return self.__module__

def to_dict(self) -> Dict:
as_dict = {
"name": self.name,
Expand Down
27 changes: 27 additions & 0 deletions ext.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import discord
from discord.commands import slash_command, SlashCommandGroup
from discord.ext import commands


class Temptests(commands.Cog):
def __init__(self, bot):
self.bot = bot

gtest = SlashCommandGroup("gtest", "gtest")

@gtest.command(name="dothing", description="gtest")
async def gtest_dothing(self, ctx: discord.ApplicationContext):
await ctx.respond("gtest_dothing")
print(self.bot.application_commands)
print(self.bot._application_commands)

@slash_command(name="test838")
async def test838(self, ctx: discord.ApplicationContext):
"""Test for #838"""
await ctx.respond("Test for #838")
self.bot.reload_extension("ext2")


def setup(bot):
bot.add_cog(Temptests(bot))
print('h')
16 changes: 16 additions & 0 deletions ext2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from discord.ext import commands
from discord.commands import slash_command


class Temptests2(commands.Cog):
def __init__(self, bot):
self.bot = bot

@slash_command()
async def testing838(self, ctx):
await ctx.respond("Test for #838")
self.bot.reload_extension("ext")


def setup(bot):
bot.add_cog(Temptests2(bot))
19 changes: 19 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import discord
intents = discord.Intents.all()


bot = discord.Bot(debug_guilds=[911706065836605471])
extensions = ['ext', 'ext2']
for extension in extensions:
bot.load_extension(extension)

@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
print(bot.application_commands)
print(bot._application_commands)

bot.run("OTMyNDY2OTc4NjcxNjkzODk1.YeTZjA.p4y7vE2Kw0uOC_WxPB-KO_G6VII")

0 comments on commit 19f9e45

Please sign in to comment.