11import dataclasses
2+ from typing import Sequence
23
34from discord_typings import (
45 ApplicationCommandInteractionData , ComponentInteractionData
56)
67from typing_extensions import Self
78from wumpy .models import (
8- ApplicationCommandOption , CommandInteraction as CommandInteractionModel ,
9- CommandInteractionOption ,
10- ComponentInteraction as ComponentInteractionModel , ComponentType ,
9+ ActionRow , AllowedMentions , ApplicationCommandOption ,
10+ CommandInteraction as CommandInteractionModel , CommandInteractionOption ,
11+ ComponentInteraction as ComponentInteractionModel , ComponentType , Embed ,
1112 Interaction as InteractionModel , InteractionType , Member , Message ,
1213 Permissions , ResolvedInteractionData , SelectInteractionValue , Snowflake ,
13- User
14+ User , component_data , embed_data
1415)
16+ from wumpy .rest import MISSING
1517
1618from ._compat import Request
1719
@@ -31,13 +33,34 @@ class Interaction(InteractionModel):
3133
3234 async def respond (
3335 self ,
34- content : str ,
36+ content : str = MISSING ,
37+ * ,
38+ tts : bool = MISSING ,
39+ embeds : Sequence [Embed ] = MISSING ,
40+ allowed_mentions : AllowedMentions = MISSING ,
41+ components : Sequence [ActionRow ] = MISSING ,
42+ ephemeral : bool = MISSING ,
3543 ) -> None :
44+ data = {
45+ 'content' : content ,
46+ 'tts' : tts ,
47+ }
48+
49+ if embeds is not MISSING :
50+ data ['embeds' ] = [embed_data (emb ) for emb in embeds ]
51+
52+ if allowed_mentions is not MISSING :
53+ data ['allowed_mentions' ] = allowed_mentions .data ()
54+
55+ if components is not MISSING :
56+ data ['components' ] = [component_data (comp ) for comp in components ]
57+
58+ if ephemeral is True :
59+ data ['flags' ] = 1 << 6
60+
3661 await self ._request .respond ({
3762 'type' : 4 ,
38- 'data' : {
39- 'content' : content
40- }
63+ 'data' : data
4164 })
4265
4366 async def defer (self ) -> None :
@@ -170,11 +193,32 @@ async def defer_update(self) -> None:
170193
171194 async def update (
172195 self ,
173- content : str ,
196+ content : str = MISSING ,
197+ * ,
198+ tts : bool = MISSING ,
199+ embeds : Sequence [Embed ] = MISSING ,
200+ allowed_mentions : AllowedMentions = MISSING ,
201+ components : Sequence [ActionRow ] = MISSING ,
202+ ephemeral : bool = MISSING ,
174203 ) -> None :
204+ data = {
205+ 'content' : content ,
206+ 'tts' : tts ,
207+ }
208+
209+ if embeds is not MISSING :
210+ data ['embeds' ] = [embed_data (emb ) for emb in embeds ]
211+
212+ if allowed_mentions is not MISSING :
213+ data ['allowed_mentions' ] = allowed_mentions .data ()
214+
215+ if components is not MISSING :
216+ data ['components' ] = [component_data (comp ) for comp in components ]
217+
218+ if ephemeral is True :
219+ data ['flags' ] = 1 << 6
220+
175221 await self ._request .respond ({
176222 'type' : 7 ,
177- 'data' : {
178- 'content' : content
179- }
223+ 'data' : data
180224 })
0 commit comments