Skip to content

Commit 9317dc4

Browse files
authored
fix: correct emoji parsing and component -> modal (#1283)
* fix: three fixes * feat: add myself lol
1 parent b8fe5c4 commit 9317dc4

File tree

6 files changed

+15
-9
lines changed

6 files changed

+15
-9
lines changed

interactions/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@
208208
MessageType,
209209
MFALevel,
210210
Modal,
211+
modal_callback,
211212
ModalCommand,
212213
ModalContext,
213214
MODEL_TO_CONVERTER,
@@ -527,6 +528,7 @@
527528
"Missing",
528529
"MISSING",
529530
"Modal",
531+
"modal_callback",
530532
"ModalCommand",
531533
"ModalContext",
532534
"MODEL_TO_CONVERTER",
@@ -678,6 +680,7 @@
678680
# Jimmy-Blue -- Contributor
679681
# Kigstn -- Contributor
680682
# leestarb -- Contributor
683+
# mAxYoLo01 -- Contributor
681684
# Nanrech -- Contributor
682685
# silasary -- Contributor
683686
# Toricane -- Contributor

interactions/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@
249249
MemberConverter,
250250
MessageableChannelConverter,
251251
MessageConverter,
252+
modal_callback,
252253
ModalCommand,
253254
ModalContext,
254255
MODEL_TO_CONVERTER,
@@ -457,6 +458,7 @@
457458
"MessageType",
458459
"MFALevel",
459460
"Modal",
461+
"modal_callback",
460462
"ModalCommand",
461463
"ModalContext",
462464
"MODEL_TO_CONVERTER",

interactions/models/discord/components.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@
55

66
import discord_typings
77

8-
from interactions.client.const import (
9-
ACTION_ROW_MAX_ITEMS,
10-
MISSING,
11-
)
8+
from interactions.client.const import ACTION_ROW_MAX_ITEMS, MISSING
129
from interactions.client.mixins.serialization import DictSerializationMixin
13-
from interactions.models.discord.emoji import PartialEmoji
14-
from interactions.models.discord.emoji import process_emoji
15-
from interactions.models.discord.enums import ButtonStyle, ComponentType, ChannelType
10+
from interactions.models.discord.emoji import PartialEmoji, process_emoji
11+
from interactions.models.discord.enums import ButtonStyle, ChannelType, ComponentType
1612

1713
__all__ = (
1814
"BaseComponent",
@@ -245,10 +241,12 @@ def __init__(
245241

246242
@classmethod
247243
def from_dict(cls, data: discord_typings.ButtonComponentData) -> "Button":
244+
emoji = process_emoji(data.get("emoji"))
245+
emoji = PartialEmoji.from_dict(emoji) if emoji else None
248246
return cls(
249247
style=ButtonStyle(data["style"]),
250248
label=data.get("label"),
251-
emoji=process_emoji(data.get("emoji")),
249+
emoji=emoji,
252250
custom_id=data.get("custom_id"),
253251
url=data.get("url"),
254252
disabled=data.get("disabled", False),

interactions/models/internal/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
LocalisedName,
2727
LocalizedDesc,
2828
LocalizedName,
29+
modal_callback,
2930
ModalCommand,
3031
OptionType,
3132
slash_command,
@@ -156,6 +157,7 @@
156157
"MemberConverter",
157158
"MessageableChannelConverter",
158159
"MessageConverter",
160+
"modal_callback",
159161
"ModalCommand",
160162
"ModalContext",
161163
"MODEL_TO_CONVERTER",

interactions/models/internal/application_commands.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"LocalisedName",
6767
"LocalizedDesc",
6868
"LocalizedName",
69+
"modal_callback",
6970
"ModalCommand",
7071
"OptionType",
7172
"slash_command",

interactions/models/internal/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ def target(self) -> None | Message | User | Member:
621621
return self.resolved.get(self.target_id)
622622

623623

624-
class ComponentContext(InteractionContext):
624+
class ComponentContext(InteractionContext, ModalMixin):
625625
values: list[str]
626626
"""The values of the SelectMenu component, if any."""
627627
custom_id: str

0 commit comments

Comments
 (0)