forked from itscynxx/Spectre
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a command to generate a link that searches NorthstarDocs with the passed search term
- Loading branch information
1 parent
3523090
commit dd93bb9
Showing
2 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from discord.ext import commands | ||
import urllib | ||
|
||
|
||
class DocSearch(commands.Cog): | ||
def __init__(self, bot: commands.Bot) -> None: | ||
self.bot = bot | ||
|
||
@commands.hybrid_command( | ||
description="Generates a search query link for NorthstarDocs based on search term" | ||
) | ||
async def docsearch(self, ctx, *, query): | ||
query = query.replace(" ", "+") | ||
# convert special characters to link friendly format | ||
urllib.parse.quote_plus(query) | ||
await ctx.send(f"https://docs.northstar.tf/?q={query}") | ||
|
||
|
||
async def setup(bot: commands.Bot) -> None: | ||
await bot.add_cog(DocSearch(bot)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters