|
1 | | -from discord_message_components.components import SelectMenu |
2 | | -from requests import api |
3 | 1 | from .slash.http import create_global_command, create_guild_command, delete_global_command, delete_guild_command, delete_guild_commands, edit_global_command, edit_guild_command, get_command, get_global_commands, get_guild_commands, delete_global_commands, get_id |
4 | 2 | from .slash.types import OptionTypes, SlashCommand, SlashOption, SubSlashCommand, SubSlashCommandGroup |
5 | 3 | from .tools import MISSING, get, get_index |
@@ -51,7 +49,7 @@ class Slash(): |
51 | 49 | .. code-block:: |
52 | 50 |
|
53 | 51 | ... |
54 | | - @slash.slashcommand(name="my_command", description="this is my slash command", options=[SlashOption(str, "option", "this is an option")]) |
| 52 | + @slash.command(name="my_command", description="this is my slash command", options=[SlashOption(str, "option", "this is an option")]) |
55 | 53 | async def command(ctx: SlashedCommand): |
56 | 54 | ... |
57 | 55 | |
@@ -146,14 +144,14 @@ async def _socket_response(self, msg): |
146 | 144 | # find the key name |
147 | 145 | for op in fixed_options: |
148 | 146 | if options[op["name"]] == u: |
149 | | - options[op["name"]] = discord.User(state=self._discord._get_state(), data=resolved_user) |
| 147 | + options[op["name"]] = discord.User(state=self._discord._connection, data=resolved_user) |
150 | 148 | if resolved.get('members'): |
151 | 149 | for m in resolved["members"]: |
152 | 150 | resolved_member = resolved["members"][m] |
153 | 151 | # find the key name |
154 | 152 | for op in fixed_options: |
155 | 153 | if options[op["name"]] == m: |
156 | | - options[op["name"]] = discord.Member(state=self._discord._get_state(), data=resolved_member, guild=self._discord.get_guild(data["guild_id"])) |
| 154 | + options[op["name"]] = discord.Member(state=self._discord._connection, data=resolved_member, guild=self._discord.get_guild(data["guild_id"])) |
157 | 155 | else: |
158 | 156 | for op in fixed_options: |
159 | 157 | if op["type"] == OptionTypes.USER: |
@@ -375,7 +373,7 @@ async def nuke_commands(self): |
375 | 373 | print("nuked") |
376 | 374 |
|
377 | 375 |
|
378 | | - def slashcommand(self, name, description=MISSING, options=MISSING, guild_ids=MISSING, default_permission=True, guild_permissions=MISSING): |
| 376 | + def command(self, name, description=MISSING, options=MISSING, guild_ids=MISSING, default_permission=True, guild_permissions=MISSING): |
379 | 377 | """A decorator for a slash command |
380 | 378 | |
381 | 379 | command in discord: |
@@ -420,7 +418,7 @@ def slashcommand(self, name, description=MISSING, options=MISSING, guild_ids=MIS |
420 | 418 | ------- |
421 | 419 | .. code-block:: |
422 | 420 |
|
423 | | - @extension.slash.slashcommand(name="hello_world", description="This is a test command", options=[ |
| 421 | + @extension.slash.command(name="hello_world", description="This is a test command", options=[ |
424 | 422 | SlashOption(str, name="parameter", description="this is a parameter", choices=[{ "name": "choice 1", "value": "test" }]) |
425 | 423 | ], guild_ids=["785567635802816595"], default_permission=False, guild_permissions={ |
426 | 424 | "785567635802816595": SlashPermission(allowed_ids={"539459006847254542": SlashPermission.USER}) |
@@ -598,13 +596,13 @@ async def _on_socket_response(self, msg): |
598 | 596 |
|
599 | 597 | if data["type"] != 3: |
600 | 598 | return |
601 | | - |
| 599 | + |
602 | 600 | guild = await self._discord.fetch_guild(data["guild_id"]) |
603 | 601 | user = discord.Member(data=data["member"], guild=guild, state=self._discord._connection) |
604 | 602 |
|
605 | 603 |
|
606 | | - msg = await getResponseMessage(self._discord, data=data, user=user, response=True) |
607 | | - component = EphemeralComponent(self._discord, user, data) if data["message"]["flags"] == 64 else msg.interaction_component |
| 604 | + msg = await getResponseMessage(self._discord._connection, data=data, application_id=self._discord.user.id, user=user, response=True) |
| 605 | + component = EphemeralComponent(self._discord.user.id, state=self._discord._connection, user=user, data=data) if data["message"]["flags"] == 64 else msg.interaction_component |
608 | 606 |
|
609 | 607 | # Get listening components with the same custom id |
610 | 608 | _listening_components = [x for x in self._listening_components if data["data"]["custom_id"] == x[1]] |
|
0 commit comments