MCPcopy Create free account
hub / github.com/RocketGod-git/shodanbot / button_callback

Method button_callback

main.py:392–416  ·  view source on GitHub ↗
(self, interaction: discord.Interaction, max_results: int)

Source from the content-addressed store, hash-verified

390
391
392 async def button_callback(self, interaction: discord.Interaction, max_results: int):
393 if not interaction.response.is_done():
394 await interaction.response.defer()
395
396 # Disable the buttons in the view
397 for child in self.children:
398 child.disabled = True
399
400 # Immediately edit the original QueryModal message to remove the content or view
401 if self.query_message_id:
402 try:
403 message_channel = interaction.channel
404 query_message = await message_channel.fetch_message(self.query_message_id)
405 await query_message.edit(content="Processing your request...", view=None)
406 # logger.info(f"Successfully edited QueryModal message with ID: {self.query_message_id} to indicate processing.")
407 except discord.NotFound:
408 logger.error(f"QueryModal message with ID {self.query_message_id} not found. It might have been deleted.")
409 except discord.Forbidden:
410 logger.error(f"Bot does not have permissions to edit QueryModal message with ID {self.query_message_id}.")
411 except discord.HTTPException as e:
412 logger.error(f"Failed to edit QueryModal message due to HTTPException: {e}")
413 except Exception as e:
414 logger.error(f"Unexpected error occurred when trying to edit QueryModal message with ID {self.query_message_id}: {e}")
415
416 await self.handle_search(interaction, max_results)
417
418
419 @discord.ui.button(label="20", style=discord.ButtonStyle.primary, custom_id="max_results_20")

Callers 4

twenty_results_buttonMethod · 0.95
fifty_results_buttonMethod · 0.95

Calls 1

handle_searchMethod · 0.95

Tested by

no test coverage detected