@@ -173,19 +173,24 @@ async def synchronize(self, payload: Optional[ApplicationCommand] = None) -> Non
173173 )
174174 command_names : List [str ] = [command ["name" ] for command in commands ]
175175
176- async def create () -> None :
176+ async def create (data : ApplicationCommand ) -> None :
177177 """
178178 Creates a new application command in the API if one does not exist for it.
179+ :param data: The data of the command to create.
180+ :type data: ApplicationCommand
179181 """
180- log .debug ("A command was not found in the API, creating and adding to the cache." )
182+ log .debug (
183+ f"Command { data .name } was not found in the API, creating and adding to the cache."
184+ )
185+
181186 request = await self .http .create_application_command (
182- application_id = self .me .id , data = payload ._json , guild_id = payload .guild_id
187+ application_id = self .me .id , data = data ._json , guild_id = data .guild_id
183188 )
184189
185190 if request .get ("code" ):
186191 raise JSONException (request ["code" ])
187192 else :
188- self .http .cache .interactions .add (Build (id = payload .name , value = payload ))
193+ self .http .cache .interactions .add (Build (id = data .name , value = data ))
189194
190195 if commands :
191196 log .debug ("Commands were found, checking for sync." )
@@ -233,12 +238,13 @@ async def create() -> None:
233238 raise JSONException (request ["code" ])
234239 break
235240 else :
236- await create ()
241+ await create (payload )
237242 else :
238243 log .debug (f"Adding command { result .name } to cache." )
239244 self .http .cache .interactions .add (Build (id = result .name , value = result ))
240245 else :
241- await create ()
246+ if payload :
247+ await create (payload )
242248
243249 cached_commands : List [dict ] = [command for command in self .http .cache .interactions .view ()]
244250 cached_command_names = [command ["name" ] for command in cached_commands ]
0 commit comments