@@ -12,9 +12,14 @@ class CustomRoute(Route):
1212
1313
1414class SlashCommandRequest :
15- def __init__ (self , logger , _discord ):
15+ def __init__ (self , logger , _discord , application_id ):
1616 self .logger = logger
1717 self ._discord : typing .Union [discord .Client , discord .AutoShardedClient ] = _discord
18+ self ._application_id = application_id
19+
20+ @property
21+ def application_id (self ):
22+ return self ._application_id or self ._discord .user .id
1823
1924 def put_slash_commands (self , slash_commands : list , guild_id ):
2025 """
@@ -73,7 +78,7 @@ def command_request(self, method, guild_id, url_ending="", **kwargs):
7378 :param url_ending: String to append onto the end of the url.
7479 :param \**kwargs: Kwargs to pass into discord.py's `request function <https://github.com/Rapptz/discord.py/blob/master/discord/http.py#L134>`_
7580 """
76- url = f"/applications/{ self ._discord . user . id } "
81+ url = f"/applications/{ self .application_id } "
7782 url += "/commands" if not guild_id else f"/guilds/{ guild_id } /commands"
7883 url += url_ending
7984 route = CustomRoute (method , url )
@@ -120,12 +125,13 @@ def command_response(self, token, use_webhook, method, interaction_id= None, url
120125 """
121126 if not use_webhook and not interaction_id :
122127 raise error .IncorrectFormat ("Internal Error! interaction_id must be set if use_webhook is False" )
123- req_url = f"/webhooks/{ self ._discord . user . id } /{ token } " if use_webhook else f"/interactions/{ interaction_id } /{ token } /callback"
128+ req_url = f"/webhooks/{ self .application_id } /{ token } " if use_webhook else f"/interactions/{ interaction_id } /{ token } /callback"
124129 req_url += url_ending
125130 route = CustomRoute (method , req_url )
126131 return self ._discord .http .request (route , ** kwargs )
127132
128133 def post_with_files (self , _resp , files : typing .List [discord .File ], token ):
134+
129135 form = aiohttp .FormData ()
130136 form .add_field ("payload_json" , json .dumps (_resp ))
131137 for x in range (len (files )):
@@ -147,6 +153,7 @@ def edit(self, _resp, token, message_id="@original"):
147153 req_url = f"/messages/{ message_id } "
148154 return self .command_response (token , True , "PATCH" , url_ending = req_url , json = _resp )
149155
156+
150157 def delete (self , token , message_id = "@original" ):
151158 """
152159 Sends delete command response POST request to Discord API.
@@ -157,3 +164,4 @@ def delete(self, token, message_id="@original"):
157164 """
158165 req_url = f"/messages/{ message_id } "
159166 return self .command_response (token , True , "DELETE" , url_ending = req_url )
167+
0 commit comments