Skip to content

Commit c8a0b5e

Browse files
committed
Make cog menus work.
1 parent 9fb64fd commit c8a0b5e

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

discord_slash/client.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,10 @@ async def to_dict(self):
326326
"options": selected.options or [],
327327
"default_permission": selected.default_permission,
328328
"permissions": {},
329-
"type": 1,
329+
"type": selected._type,
330330
}
331+
if command_dict["type"] != 1:
332+
command_dict.pop("description")
331333
if y in selected.permissions:
332334
command_dict["permissions"][y] = selected.permissions[y]
333335
wait[y][x] = copy.deepcopy(command_dict)
@@ -340,8 +342,10 @@ async def to_dict(self):
340342
"options": selected.options or [],
341343
"default_permission": selected.default_permission,
342344
"permissions": selected.permissions or {},
343-
"type": 1,
345+
"type": selected._type,
344346
}
347+
if command_dict["type"] != 1:
348+
command_dict.pop("description")
345349
wait["global"][x] = copy.deepcopy(command_dict)
346350

347351
# Separated normal command add and subcommand add not to
@@ -637,6 +641,18 @@ def add_slash_command(
637641
self.logger.debug(f"Added command `{name}`")
638642
return obj
639643

644+
def _cog_ext_add_context_menu(self, target: int, name: str, guild_ids: list = None):
645+
"""
646+
Creates a new cog_based context menu command.
647+
648+
:param cmd: Command Coroutine.
649+
:type cmd: Coroutine
650+
:param name: The name of the command
651+
:type name: str
652+
:param _type: The context menu type.
653+
:type _type: int
654+
"""
655+
640656
def add_context_menu(self, cmd, name: str, _type: int, guild_ids: list = None):
641657
"""
642658
Creates a new context menu command.

discord_slash/cog_ext.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,9 @@ def wrapper(cmd):
191191

192192
# I don't feel comfortable with having these right now, they're too buggy even when they were working.
193193

194-
"""
194+
195195
def cog_context_menu(name: str, guild_ids: list = None, target: int = 1):
196-
"""
197-
"""
196+
"""
198197
Decorator that adds context menu commands.
199198
200199
:param target: The type of menu.
@@ -203,8 +202,7 @@ def cog_context_menu(name: str, guild_ids: list = None, target: int = 1):
203202
:type name: str
204203
:param guild_ids: A list of guild IDs to register the command under. Defaults to ``None``.
205204
:type guild_ids: list
206-
"""
207-
"""
205+
"""
208206

209207
def wrapper(cmd):
210208
# _obj = self.add_slash_command(
@@ -232,7 +230,6 @@ def wrapper(cmd):
232230
return CogBaseCommandObject(name or cmd.__name__, _cmd, target)
233231

234232
return wrapper
235-
"""
236233

237234

238235
def permission(guild_id: int, permissions: list):

0 commit comments

Comments
 (0)