mirror of
https://github.com/stijndcl/didier.git
synced 2026-04-07 15:48:29 +02:00
Separate loading slash commands from normal commands, split slash commands to separate cogs, make init_extensions support directories
This commit is contained in:
parent
ed0649c953
commit
831459a321
4 changed files with 72 additions and 43 deletions
30
cogs/slash/google_slash.py
Normal file
30
cogs/slash/google_slash.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
from discord.ext import commands
|
||||
from dislash import slash_command, SlashInteraction, Option, OptionType
|
||||
from functions.scrapers.google import google_search, create_google_embed
|
||||
from startup.didier import Didier
|
||||
|
||||
|
||||
class GoogleSlash(commands.Cog):
|
||||
def __init__(self, client: Didier):
|
||||
self.client: Didier = client
|
||||
|
||||
@slash_command(name="google",
|
||||
description="Google search",
|
||||
options=[
|
||||
Option("query", "Search query", OptionType.STRING, required=True)
|
||||
],
|
||||
guild_ids=[728361030404538488, 880175869841277008]
|
||||
)
|
||||
async def _google_slash(self, interaction: SlashInteraction, query: str):
|
||||
result = google_search(query)
|
||||
|
||||
if not result.results:
|
||||
return await interaction.reply("Er ging iets fout (Response {})".format(result.status_code))
|
||||
|
||||
embed = create_google_embed(result)
|
||||
print("got here")
|
||||
await interaction.reply(embed=embed)
|
||||
|
||||
|
||||
def setup(client: Didier):
|
||||
client.add_cog(GoogleSlash(client))
|
||||
Loading…
Add table
Add a link
Reference in a new issue