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
|
|
@ -1,5 +1,6 @@
|
|||
from typing import Optional, List
|
||||
|
||||
import discord
|
||||
from bs4 import BeautifulSoup
|
||||
from dataclasses import dataclass
|
||||
from requests import get
|
||||
|
|
@ -55,3 +56,24 @@ def google_search(query) -> SearchResult:
|
|||
links.append(f"[{title}]({link})")
|
||||
|
||||
return SearchResult(200, links[:10])
|
||||
|
||||
|
||||
def create_google_embed(result: SearchResult) -> discord.Embed:
|
||||
embed = discord.Embed(colour=discord.Colour.blue())
|
||||
embed.set_author(name="Google Search")
|
||||
|
||||
# Empty list of results
|
||||
if len(result.results) == 0:
|
||||
embed.colour = discord.Colour.red()
|
||||
embed.description = "Geen resultaten gevonden."
|
||||
return embed
|
||||
|
||||
# Add results into a field
|
||||
links = []
|
||||
|
||||
for index, link in enumerate(result.results):
|
||||
links.append(f"{index + 1}: {link}")
|
||||
|
||||
embed.description = "\n".join(links)
|
||||
|
||||
return embed
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue