Skip to content

Commit cc63233

Browse files
committed
Merge branch 'permissions' of https://github.com/benwoo1110/discord-py-slash-command into permissions
2 parents 8001dec + 22e9e86 commit cc63233

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

discord_slash/client.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,7 @@ def get_cog_commands(self, cog: commands.Cog):
126126
self.commands[x.base].allowed_guild_ids.append(i)
127127
self.commands[x.base].has_subcommands = True
128128
else:
129-
_cmd = {
130-
"func": None,
131-
"description": x.base_description,
132-
"auto_convert": {},
133-
"guild_ids": x.allowed_guild_ids.copy(),
134-
"api_options": [],
135-
"api_permissions": [],
136-
"has_subcommands": True,
137-
"connector": {}
138-
}
139-
self.commands[x.base] = model.BasecommandObject(x.base, _cmd)
129+
self.commands[x.base] = model.BasecommandObject(x.base, x.base_command_data)
140130
if x.base not in self.subcommands:
141131
self.subcommands[x.base] = {}
142132
if x.subcommand_group:

discord_slash/cog_ext.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ def cog_subcommand(*,
7171
description: str = None,
7272
base_description: str = None,
7373
base_desc: str = None,
74+
base_default_permission: bool = True,
75+
base_permissions: dict = None,
7476
subcommand_group_description: str = None,
7577
sub_group_desc: str = None,
7678
guild_ids: typing.List[int] = None,
@@ -103,6 +105,10 @@ async def group_say(self, ctx: SlashContext, text: str):
103105
:param base_description: Description of the base command. Default ``None``.
104106
:type base_description: str
105107
:param base_desc: Alias of ``base_description``.
108+
:param base_default_permission: Sets if users have permission to run slash command by default, when no permissions are set. Default ``True``.
109+
:type base_default_permission: bool
110+
:param base_permissions: Permission requirements of the slash command. Default ``None``.
111+
:type base_permissions: dict
106112
:param subcommand_group_description: Description of the subcommand_group. Default ``None``.
107113
:type subcommand_group_description: str
108114
:param sub_group_desc: Alias of ``subcommand_group_description``.
@@ -123,6 +129,17 @@ def wrapper(cmd):
123129
else:
124130
opts = options
125131

132+
_cmd = {
133+
"func": None,
134+
"description": base_description,
135+
"guild_ids": guild_ids.copy(),
136+
"api_options": [],
137+
"default_permission": base_default_permission,
138+
"api_permissions": base_permissions,
139+
"connector": {},
140+
"has_subcommands": True
141+
}
142+
126143
_sub = {
127144
"func": cmd,
128145
"name": name or cmd.__name__,
@@ -133,5 +150,5 @@ def wrapper(cmd):
133150
"api_options": opts,
134151
"connector": connector
135152
}
136-
return CogSubcommandObject(_sub, base, name or cmd.__name__, subcommand_group)
153+
return CogSubcommandObject(base, _cmd, subcommand_group, name or cmd.__name__, _sub)
137154
return wrapper

discord_slash/model.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,9 @@ class CogSubcommandObject(SubcommandObject):
255255
Do not manually init this model.
256256
"""
257257

258-
def __init__(self, *args):
259-
super().__init__(*args)
258+
def __init__(self, base, cmd, sub_group, name, sub):
259+
super().__init__(sub, base, name, sub_group)
260+
self.base_command_data = cmd
260261
self.cog = None # Manually set this later.
261262

262263
async def invoke(self, *args, **kwargs):

0 commit comments

Comments
 (0)