Skip to content
This repository was archived by the owner on Mar 8, 2022. It is now read-only.

Commit 028ecd4

Browse files
author
kuso-senpai
committed
fixed response issues
1 parent cabf5b6 commit 028ecd4

File tree

10 files changed

+153
-99
lines changed

10 files changed

+153
-99
lines changed

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,39 @@ You can find more examples [here](./examples)
109109

110110
### **Added**
111111
- Slashcomamnd support
112+
- `Slash` class for slash commands
113+
- `Slash.command`, `Slash.subcommand` and `Slash.subcommand_groups` are available for creating slash commands
114+
- `SlashedCommand` and `SlashedSubCommand` are there for used slash commands
115+
112116
- ``Message``
113117
- disable_action_row(row_numbers: `int` | `range`, disable: `bool`)
118+
> disables (enables) component row(s) in the message
119+
114120
- disable_components(disable: `bool`)
115-
- set_edit
121+
> disables (enables) all componentss
122+
123+
- overrides
124+
- `Messageable.send` returns Message instead of discord.Message and takes components parameter
125+
- `override_client` function added
126+
127+
- `interaction.send`, creates followup messages which can be hidden
128+
129+
- `Component.listening_component`
130+
> A listening component with a callback function that will always be executed whenever a component with the specified custom_id
131+
was used
132+
133+
134+
## **Changed**
135+
- Message
136+
137+
- All Message objects don't use the client object anymore
138+
- Message.wait_for now needs the client as the first parameter
139+
140+
141+
## **Fixed**
142+
- Interaction
143+
> All interaction responses work now
144+
- A lot of issues I fogor💀
116145

117146
</details>
118147

discord_message_components/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from .client import Components, Slash, Extension
22
from .components import ActionRow, Button, LinkButton, SelectMenu, SelectOption, Colors
33
from .slash.types import OptionTypes, SlashPermission, SlashOption
4-
from .receive import ResponseMessage, Message, PressedButton, SelectedMenu, SlashedCommand, SlashedSubCommand
4+
from .receive import ResponseMessage, Message, PressedButton, SelectedMenu, SlashedCommand, SlashedSubCommand, EphemeralComponent, EphemeralMessage
55
from .override import Overriden_Bot, override_client
66

77

discord_message_components/client.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from discord_message_components.components import SelectMenu
2-
from requests import api
31
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
42
from .slash.types import OptionTypes, SlashCommand, SlashOption, SubSlashCommand, SubSlashCommandGroup
53
from .tools import MISSING, get, get_index
@@ -51,7 +49,7 @@ class Slash():
5149
.. code-block::
5250
5351
...
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")])
5553
async def command(ctx: SlashedCommand):
5654
...
5755
@@ -146,14 +144,14 @@ async def _socket_response(self, msg):
146144
# find the key name
147145
for op in fixed_options:
148146
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)
150148
if resolved.get('members'):
151149
for m in resolved["members"]:
152150
resolved_member = resolved["members"][m]
153151
# find the key name
154152
for op in fixed_options:
155153
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"]))
157155
else:
158156
for op in fixed_options:
159157
if op["type"] == OptionTypes.USER:
@@ -375,7 +373,7 @@ async def nuke_commands(self):
375373
print("nuked")
376374

377375

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):
379377
"""A decorator for a slash command
380378
381379
command in discord:
@@ -420,7 +418,7 @@ def slashcommand(self, name, description=MISSING, options=MISSING, guild_ids=MIS
420418
-------
421419
.. code-block::
422420
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=[
424422
SlashOption(str, name="parameter", description="this is a parameter", choices=[{ "name": "choice 1", "value": "test" }])
425423
], guild_ids=["785567635802816595"], default_permission=False, guild_permissions={
426424
"785567635802816595": SlashPermission(allowed_ids={"539459006847254542": SlashPermission.USER})
@@ -598,13 +596,13 @@ async def _on_socket_response(self, msg):
598596

599597
if data["type"] != 3:
600598
return
601-
599+
602600
guild = await self._discord.fetch_guild(data["guild_id"])
603601
user = discord.Member(data=data["member"], guild=guild, state=self._discord._connection)
604602

605603

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
608606

609607
# Get listening components with the same custom id
610608
_listening_components = [x for x in self._listening_components if data["data"]["custom_id"] == x[1]]

discord_message_components/components.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -838,11 +838,11 @@ class Colors:
838838
"""
839839
A list of button styles (colors) in message components
840840
"""
841-
Primary = blurple = 1
842-
Secondary = grey = 2
843-
Succes = green = 3
844-
Danger = red = 4
845-
URL = 5
841+
Primary = blurple = 1
842+
Secondary = grey = 2
843+
Succes = green = 3
844+
Danger = red = 4
845+
URL = 5
846846

847847
@classmethod
848848
def getColor(cls, s):

discord_message_components/http.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from discord_message_components.components import ActionRow
22
from discord.message import Attachment
33
from .tools import MISSING
4-
import json
5-
import discord
64

5+
import discord
76
from discord.http import Route
7+
8+
import json
89
from typing import Any, List
910

10-
url = "https://discord.com/api/v8"
1111

1212
class BetterRoute(Route):
1313
BASE = "https://discord.com/api/v9"

discord_message_components/override.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from .client import Components, Slash
22
import discord
3-
from discord import TextChannel
43
from discord.ext import commands
54

65
from .receive import Message
@@ -10,8 +9,7 @@
109
module = sys.modules["discord"]
1110

1211

13-
14-
async def send(self: TextChannel, content=None, *, tts=False, embed=None, embeds=None, file=None,
12+
async def send(self: discord.TextChannel, content=None, *, tts=False, embed=None, embeds=None, file=None,
1513
files=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None,
1614
mention_author=None, components=None) -> Message:
1715
"""Sends a message to a textchannel

0 commit comments

Comments
 (0)