edit some stuff

This commit is contained in:
driftywinds
2025-05-11 18:16:27 +00:00
parent 56a1f0edfc
commit 4e71faf0fe

View File

@@ -17,7 +17,7 @@ load_dotenv()
API_BASE_URL = os.getenv("API_BASE_URL") # Configure in .env
BEARER_TOKEN = os.getenv("BEARER_TOKEN") # Configure in .env
DISCORD_TOKEN = os.getenv("DISCORD_TOKEN") # Configure in .env
ALLOWED_CHANNELS = [123456789] # REPLACE WITH YOUR CHANNEL IDS
ALLOWED_CHANNELS = [123456789] # Replace with your channel IDs
# UUID validation pattern
UUID_PATTERN = re.compile(r'^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$')
@@ -34,6 +34,7 @@ class SearchResultsView(View):
def __init__(self, results):
super().__init__(timeout=60)
self.results = results
self.original_message = None
self.add_buttons()
def add_buttons(self):
@@ -50,6 +51,11 @@ class ResultButton(Button):
self.item = item
async def callback(self, interaction: discord.Interaction):
if self.view.original_message:
try:
await self.view.original_message.delete()
except (discord.NotFound, discord.Forbidden):
pass
await self.show_addon_embed(interaction)
async def show_addon_embed(self, interaction: discord.Interaction):
@@ -110,13 +116,10 @@ async def on_message(message):
if message.author == bot.user:
return
# Channel check
# the below line will make it so the bot does not reply in DMs
# if message.channel.id not in ALLOWED_CHANNELS:
# Allow DMs and specified channels
if not isinstance(message.channel, discord.DMChannel) and message.channel.id not in ALLOWED_CHANNELS:
return
# Command prefix check
if not message.content.startswith('!mpbot'):
return
@@ -175,7 +178,8 @@ async def perform_search(ctx, query):
)
view = SearchResultsView(search_data)
await ctx.send(embed=embed, view=view)
sent_message = await ctx.send(embed=embed, view=view)
view.original_message = sent_message
except requests.exceptions.HTTPError as e:
embed = discord.Embed(