Skip to content

Commit cf7e72d

Browse files
committed
Prepare for release.
1 parent d418231 commit cf7e72d

File tree

6 files changed

+21
-94
lines changed

6 files changed

+21
-94
lines changed

bot.py

Lines changed: 0 additions & 47 deletions
This file was deleted.

cog.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

discord_slash/client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ async def sync_all_commands(
467467
if ex.status == 400:
468468
# catch bad requests
469469
cmd_nums = set(
470-
re.findall(r"In\s(\d).", ex.args[0])
470+
re.findall(r"^[\w-]{1,32}$", ex.args[0])
471471
) # find all discords references to commands
472472
error_string = ex.args[0]
473473

@@ -680,8 +680,6 @@ def add_context_menu(self, cmd, name: str, _type: int, guild_ids: list = None):
680680
"api_permissions": {},
681681
}
682682

683-
print("add_context_menu".upper(), ": ", _cmd)
684-
685683
obj = model.BaseCommandObject(name, cmd=_cmd, _type=_type)
686684
self.commands["context"][name] = obj
687685
self.logger.debug(f"Added context command `{name}`")
@@ -1374,13 +1372,15 @@ async def on_socket_response(self, msg):
13741372
if msg["t"] != "INTERACTION_CREATE":
13751373
return
13761374

1377-
print("on_socket_response".upper(), ": ", msg)
13781375
to_use = msg["d"]
13791376
interaction_type = to_use["type"]
13801377
if interaction_type in (1, 2, 3) or msg["s"] == 5:
13811378
await self._on_slash(to_use)
13821379
await self._on_context_menu(to_use)
1383-
await self._on_component(to_use)
1380+
try:
1381+
await self._on_component(to_use) # noqa
1382+
except KeyError:
1383+
pass # for some reason it complains about custom_id being an optional arg when it's fine?
13841384
return
13851385
# raise NotImplementedError
13861386

@@ -1447,7 +1447,7 @@ async def _on_context_menu(self, to_use):
14471447
cmd_name = to_use["data"]["name"]
14481448

14491449
if cmd_name not in self.commands["context"] and cmd_name in self.subcommands:
1450-
return # menus don't have subcommands you smooth brain
1450+
return # menus don't have subcommands you smooth brain
14511451

14521452
selected_cmd = self.commands["context"][cmd_name]
14531453

discord_slash/cog_ext.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,12 @@ def wrapper(cmd):
189189
return wrapper
190190

191191

192-
def cog_context_menu(target: int, name: str, guild_ids: list = None):
193-
"""
192+
# I don't feel comfortable with having these right now, they're too buggy even when they were working.
193+
194+
"""
195+
def cog_context_menu(name: str, guild_ids: list = None, target: int = 1):
196+
"""
197+
"""
194198
Decorator that adds context menu commands.
195199
196200
:param target: The type of menu.
@@ -199,7 +203,8 @@ def cog_context_menu(target: int, name: str, guild_ids: list = None):
199203
:type name: str
200204
:param guild_ids: A list of guild IDs to register the command under. Defaults to ``None``.
201205
:type guild_ids: list
202-
"""
206+
"""
207+
"""
203208
204209
def wrapper(cmd):
205210
# _obj = self.add_slash_command(
@@ -227,6 +232,7 @@ def wrapper(cmd):
227232
return CogBaseCommandObject(name or cmd.__name__, _cmd, target)
228233
229234
return wrapper
235+
"""
230236

231237

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

discord_slash/context.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,12 @@ def __init__(
6565
self.channel_id = int(_json["channel_id"])
6666
if self.guild:
6767
self.author = discord.Member(
68-
data=_json["member"],
69-
state=self.bot._connection,
70-
guild=self.guild
68+
data=_json["member"], state=self.bot._connection, guild=self.guild
7169
)
7270
elif self.guild_id:
73-
self.author = discord.User(
74-
data=_json["member"]["user"],
75-
state=self.bot._connection
76-
)
71+
self.author = discord.User(data=_json["member"]["user"], state=self.bot._connection)
7772
else:
78-
self.author = discord.User(
79-
data=_json["user"],
80-
state=self.bot._connection
81-
)
73+
self.author = discord.User(data=_json["user"], state=self.bot._connection)
8274
self.created_at: datetime.datetime = snowflake_time(int(self.interaction_id))
8375

8476
@property
@@ -680,7 +672,7 @@ def __init__(
680672
super().__init__(_http=_http, _json=_json, _discord=_discord, logger=logger)
681673
self.target_id = self.data["target_id"]
682674
self.context_type = _json["type"]
683-
675+
684676
try:
685677
self.menu_authors = (
686678
self.data["resolved"]["members"] if "resolved" in self.data.keys() else None
@@ -698,9 +690,7 @@ def __init__(
698690
if self.guild and self.context_author:
699691
print(self.context_author)
700692
self.context_author = discord.Member(
701-
data=self.context_author,
702-
state=self.bot._connection,
703-
guild=self.guild
693+
data=self.context_author, state=self.bot._connection, guild=self.guild
704694
)
705695

706696
try:

discord_slash/model.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,7 @@ class CogBaseCommandObject(BaseCommandObject):
374374
"""
375375

376376
def __init__(self, *args):
377-
# this is a really bad way to add context menu support
378-
# but i cannot be bothered anymore to make it better until
379-
# v4.0 is out for rewrite. sorry!
380-
_arg = 1 if not args[0] else args[0]
381-
values = [arg for arg in args]
382-
values[0] = _arg
383-
super().__init__(*values)
377+
super().__init__(*args)
384378
self.cog = None # Manually set this later.
385379

386380

0 commit comments

Comments
 (0)