Skip to content
This repository was archived by the owner on Dec 18, 2021. It is now read-only.

Commit a24f404

Browse files
committed
feat: just edit components (context)
1 parent 88661d0 commit a24f404

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

discord_components/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ async def edit_component_msg(
239239
state = self.bot._get_state()
240240
data = {**self._get_components_json(components), **options}
241241

242+
if content:
243+
data["content"] = content
244+
242245
if embed:
243246
embed = embed.to_dict()
244247
data["embed"] = embed

discord_components/context.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ async def respond(
107107
tts=False,
108108
flags=FlagsType.Ephemeral,
109109
components=[],
110+
**options,
110111
) -> None:
111112
"""Sends response to Discord.
112113
@@ -140,12 +141,19 @@ async def respond(
140141
return
141142

142143
state = self.bot._get_state()
144+
data = {**self._get_components_json(components), **options}
145+
146+
if content:
147+
data["content"] = content
143148

144149
if embed and embeds:
145150
embeds.append(embed)
146151
elif embed:
147152
embeds = [embed]
148153

154+
if embeds:
155+
data["embeds"] = embeds
156+
149157
if len(embeds) > 10:
150158
raise InvalidArgument("Embed limit exceeded. (Max: 10)")
151159
if embeds:
@@ -156,15 +164,14 @@ async def respond(
156164
allowed_mentions = state.allowed_mentions.merge(allowed_mentions).to_dict()
157165
else:
158166
allowed_mentions = allowed_mentions.to_dict()
159-
else:
160-
allowed_mentions = state.allowed_mentions and state.allowed_mentions.to_dict()
167+
168+
data["allowed_mentions"] = allowed_mentions
169+
170+
if tts is not None:
171+
data["tts"] = tts
161172

162173
data = {
163-
"content": content,
164-
"embeds": embeds,
165174
**self.client._get_components_json(components),
166-
"allowed_mentions": allowed_mentions,
167-
"tts": tts,
168175
"flags": flags,
169176
}
170177

0 commit comments

Comments
 (0)