Source code for commands.wiki_commands

import urllib.parse

import discord
from bot.weakauras_bot import WeakAurasBot
from utils.logging import get_logger, log_command

logger = get_logger(__name__)


[docs] async def send_embed_response( interaction: discord.Interaction, embed: discord.Embed, logo_file: discord.File | None, ephemeral: bool = True, ): """Helper function to send embed response with optional file attachment""" kwargs = {"embed": embed, "ephemeral": ephemeral} if logo_file: kwargs["file"] = logo_file await interaction.response.send_message(**kwargs)
[docs] def setup_wiki_commands(bot: WeakAurasBot): """Setup all wiki-related slash commands""" @bot.tree.command( name="wiki", description="Search the Warcraft Wiki for information" ) @log_command async def wiki_search(interaction: discord.Interaction, query: str): """Search warcraft.wiki.gg for the given query""" # URL encode the search query encoded_query = urllib.parse.quote_plus(query) search_url = ( f"https://warcraft.wiki.gg/wiki/Special:Search?search={encoded_query}" ) logger.info(f"Generated wiki search URL for query '{query}': {search_url}") # Create branded WeakAuras embed with proper logo handling embed, logo_file = interaction.client.create_embed( title="🔍 Warcraft Wiki Search", description=f"**Search Query:** {query}\n\n[Click here to view search results]({search_url})", footer_text="Powered by warcraft.wiki.gg", ) # Use Warcraft wiki logo as a smaller thumbnail (overrides WeakAuras logo) embed.set_thumbnail(url="https://warcraft.wiki.gg/images/Site-logo.png") await send_embed_response(interaction, embed, logo_file, ephemeral=False)