@@ -220,9 +220,11 @@ class ResponseMessage(Message):
220220 pressedButton: `PressedButton`
221221 The button which was presed
222222 acknowledge: `function`
223- Function to acknowledge the buttonPress interaction
223+ Function to acknowledge the button-press interaction
224224 respond: `function`
225225 Function to respond to the buttonPress interaction
226+ acknowledged: `bool`
227+ Whether the button was acknowledged with the acknowledge functionn
226228
227229 Attributes
228230 ----------------
@@ -329,6 +331,7 @@ def __init__(self, *, state, channel, data, user, client):
329331 super ().__init__ (state = state , channel = channel , data = data ["message" ])
330332
331333 self ._discord = client
334+ self .acknowledged = False
332335 for x in self .buttons :
333336 if hasattr (x , 'custom_id' ) and x .custom_id == data ["data" ]["custom_id" ]:
334337 self .pressedButton = PressedButton (data , user , x )
@@ -346,10 +349,14 @@ def acknowledge(self):
346349 if r .status_code == 403 :
347350 raise discord .ClientException (r .json (), "forbidden" )
348351
349- def respond (self , content = None , * , tts = False , embed = None , embeds = None , file = None , files = None , nonce = None ,
350- allowed_mentions = None , reference = None , mention_author = None , buttons = None ,
351- ninjaMode = False ):
352+ self .acknowledged = True
353+
354+ async def respond (self , content = None , * , tts = False , embed = None , embeds = None , file = None , files = None , nonce = None ,
355+ allowed_mentions = None , mention_author = None , buttons = None ,
356+ ninjaMode = False ) -> Message or None :
352357 """
358+ | coro |
359+
353360 Function to respond to the interaction
354361
355362
@@ -388,10 +395,6 @@ def respond(self, content=None, *, tts=False, embed = None, embeds=None, file=No
388395 ```
389396 Controls the mentions being processed in this message
390397 ```py
391- (discord.MessageReference or discord.Message) reference
392- ```
393- The message to refer
394- ```py
395398 (bool) mention_author
396399 ```
397400 Whether the author should be mentioned
@@ -403,23 +406,29 @@ def respond(self, content=None, *, tts=False, embed = None, embeds=None, file=No
403406 ```py
404407 (bool) ninjaMode
405408 ```
406- If true, the client will respond to the button interaction with almost nothing
409+ If true, the client will respond to the button interaction with almost nothing and returns nothing
410+
411+ Returrns
412+ -----------------------
413+ ```py
414+ (Message or None)
415+ ```
416+ The sent message if ninjaMode is false, otherwise `None`
417+
407418 """
408- if ninjaMode :
409- r = POST (self ._discord .http .token , f'https://discord.com/api/v8/interactions/{ self .pressedButton .interaction ["id" ]} /{ self .pressedButton .interaction ["token" ]} /callback' , {
410- "type" : 6
411- })
412- else :
413- json = jsonifyMessage (content = content , tts = tts , embed = embed , embeds = embeds , file = file , files = files , nonce = nonce , allowed_mentions = allowed_mentions , reference = reference , mention_author = mention_author , buttons = buttons )
414- if "embed" in json :
415- json ["embeds" ] = [json ["embed" ]]
416- del json ["embed" ]
417-
418- r = POST (self ._discord .http .token , f'https://discord.com/api/v8/interactions/{ self .pressedButton .interaction ["id" ]} /{ self .pressedButton .interaction ["token" ]} /callback' , {
419- "type" : 4 ,
420- "data" : json
421- })
419+ msg = None
420+ if not ninjaMode :
421+ json = jsonifyMessage (content = content , tts = tts , embed = embed , embeds = embeds , file = file , files = files , nonce = nonce , allowed_mentions = allowed_mentions , reference = discord .MessageReference (message_id = self .id , channel_id = self .channel .id ), mention_author = mention_author , buttons = buttons )
422+ r = POST (token = self ._discord .http .token , URL = (url + f"/channels/{ self .channel .id } /messages" ), data = json )
423+ msg = await getResponseMessage (self ._discord , r .json (), response = False )
424+
425+ r = POST (self ._discord .http .token , f'https://discord.com/api/v8/interactions/{ self .pressedButton .interaction ["id" ]} /{ self .pressedButton .interaction ["token" ]} /callback' , {
426+ "type" : 6
427+ })
428+
422429 if r .status_code == 403 :
423430 raise discord .ClientException (r .json (), "Forbidden" )
424431 if r .status_code == 400 :
425- raise discord .ClientException (r .json (), "Error while sending message" )
432+ raise discord .ClientException (r .json (), "Error while sending message" )
433+
434+ return msg
0 commit comments