mirror of https://github.com/stijndcl/didier
Start working on food, make embeds prefer title instead of author, add custom colour for ghent university blue
parent
6f0ac487cc
commit
654fbcd46b
|
@ -45,8 +45,7 @@ class Currency(commands.Cog):
|
|||
async with self.client.postgres_session as session:
|
||||
bank = await crud.get_bank(session, ctx.author.id)
|
||||
|
||||
embed = discord.Embed(colour=discord.Colour.blue())
|
||||
embed.set_author(name=f"{ctx.author.display_name}'s Bank")
|
||||
embed = discord.Embed(title=f"{ctx.author.display_name}'s Bank", colour=discord.Colour.blue())
|
||||
embed.set_thumbnail(url=ctx.author.avatar.url)
|
||||
|
||||
embed.add_field(name="Interest level", value=bank.interest_level)
|
||||
|
@ -61,8 +60,7 @@ class Currency(commands.Cog):
|
|||
async with self.client.postgres_session as session:
|
||||
bank = await crud.get_bank(session, ctx.author.id)
|
||||
|
||||
embed = discord.Embed(colour=discord.Colour.blue())
|
||||
embed.set_author(name="Bank upgrades")
|
||||
embed = discord.Embed(title="Bank upgrades", colour=discord.Colour.blue())
|
||||
|
||||
embed.add_field(
|
||||
name=f"Interest ({bank.interest_level})", value=str(interest_upgrade_price(bank.interest_level))
|
||||
|
|
|
@ -10,13 +10,12 @@ from didier import Didier
|
|||
class CustomHelpCommand(commands.MinimalHelpCommand):
|
||||
"""Customised Help command to override the default implementation
|
||||
|
||||
The default is ugly as hell so we do some fiddling with it
|
||||
The default is ugly as hell, so we do some fiddling with it
|
||||
"""
|
||||
|
||||
def _help_embed_base(self, title: str) -> discord.Embed:
|
||||
"""Create the base structure for the embeds that get sent with the Help commands"""
|
||||
embed = discord.Embed(colour=discord.Colour.blue())
|
||||
embed.set_author(name=title)
|
||||
embed = discord.Embed(title=title, colour=discord.Colour.blue())
|
||||
embed.set_footer(text="Syntax: Didier Help [Categorie] of Didier Help [Commando]")
|
||||
return embed
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
from datetime import datetime
|
||||
|
||||
from aiohttp import ClientSession
|
||||
|
||||
from didier.data.embeds.hydra import Menu
|
||||
from didier.utils.http.requests import ensure_get
|
||||
|
||||
__all__ = ["fetch_menu"]
|
||||
|
||||
|
||||
async def fetch_menu(http_session: ClientSession, day_dt: datetime) -> Menu:
|
||||
"""Fetch the menu for a given day"""
|
||||
endpoint = f"https://hydra.ugent.be/api/2.0/resto/menu/nl/{day_dt.year}/{day_dt.month}/{day_dt.day}.json"
|
||||
async with ensure_get(http_session, endpoint) as response:
|
||||
return Menu.parse_obj(response)
|
|
@ -23,8 +23,7 @@ class Deadlines(EmbedBaseModel):
|
|||
|
||||
@overrides
|
||||
def to_embed(self, **kwargs: dict) -> discord.Embed:
|
||||
embed = discord.Embed(colour=discord.Colour.dark_gold())
|
||||
embed.set_author(name="Upcoming Deadlines")
|
||||
embed = discord.Embed(title="Upcoming Deadlines", colour=discord.Colour.dark_gold())
|
||||
now = tz_aware_now()
|
||||
|
||||
has_active_deadlines = False
|
||||
|
|
|
@ -37,8 +37,7 @@ def create_error_embed(ctx: commands.Context, exception: Exception) -> discord.E
|
|||
|
||||
invocation = f"{ctx.author.display_name} in {origin}"
|
||||
|
||||
embed = discord.Embed(colour=discord.Colour.red())
|
||||
embed.set_author(name="Error")
|
||||
embed = discord.Embed(title="Error", colour=discord.Colour.red())
|
||||
embed.add_field(name="Command", value=f"{ctx.message.content}", inline=True)
|
||||
embed.add_field(name="Context", value=invocation, inline=True)
|
||||
embed.add_field(name="Exception", value=abbreviate(str(exception), Limits.EMBED_FIELD_VALUE_LENGTH), inline=False)
|
||||
|
|
|
@ -19,8 +19,7 @@ class GoogleSearch(EmbedBaseModel):
|
|||
|
||||
def _error_embed(self) -> discord.Embed:
|
||||
"""Custom embed for unsuccessful requests"""
|
||||
embed = discord.Embed(colour=discord.Colour.red())
|
||||
embed.set_author(name="Google Search")
|
||||
embed = discord.Embed(title="Google Search", colour=discord.Colour.red())
|
||||
|
||||
# Empty embed
|
||||
if not self.data.results:
|
||||
|
@ -37,8 +36,7 @@ class GoogleSearch(EmbedBaseModel):
|
|||
if not self.data.results or self.data.status_code != HTTPStatus.OK:
|
||||
return self._error_embed()
|
||||
|
||||
embed = discord.Embed(colour=discord.Colour.blue())
|
||||
embed.set_author(name="Google Search")
|
||||
embed = discord.Embed(title="Google Search", colour=discord.Colour.blue())
|
||||
embed.set_footer(text=self.data.result_stats or None)
|
||||
|
||||
# Add all results into the description
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
from .menu import Menu
|
||||
|
||||
__all__ = ["Menu"]
|
|
@ -0,0 +1,34 @@
|
|||
from typing import Literal, Optional
|
||||
|
||||
import discord
|
||||
from overrides import overrides
|
||||
from pydantic import BaseModel
|
||||
|
||||
from didier.data.embeds.base import EmbedPydantic
|
||||
from didier.utils.discord.colours import ghent_university_blue
|
||||
|
||||
__all__ = ["Menu"]
|
||||
|
||||
|
||||
class _Meal(BaseModel):
|
||||
"""Model for an item on the menu"""
|
||||
|
||||
kind: Literal["meat", "fish", "soup", "vegetarian", "vegan"]
|
||||
name: str
|
||||
price: str
|
||||
type: Literal["main", "side"]
|
||||
|
||||
|
||||
class Menu(EmbedPydantic):
|
||||
"""Embed that shows the menu in Ghent University restaurants"""
|
||||
|
||||
meals: list[_Meal] = []
|
||||
open: bool
|
||||
vegetables: list[str] = []
|
||||
message: Optional[str] = None
|
||||
|
||||
@overrides
|
||||
def to_embed(self, **kwargs: dict) -> discord.Embed:
|
||||
embed = discord.Embed(title="Menu", colour=ghent_university_blue())
|
||||
|
||||
return embed
|
|
@ -15,6 +15,7 @@ import settings
|
|||
from database.crud import ufora_announcements as crud
|
||||
from database.schemas.relational import UforaCourse
|
||||
from didier.data.embeds.base import EmbedBaseModel
|
||||
from didier.utils.discord.colours import ghent_university_blue
|
||||
from didier.utils.types.datetime import int_to_weekday
|
||||
from didier.utils.types.string import leading
|
||||
|
||||
|
@ -49,7 +50,7 @@ class UforaNotification(EmbedBaseModel):
|
|||
|
||||
def to_embed(self, **kwargs: dict) -> discord.Embed:
|
||||
"""Turn the notification into an embed"""
|
||||
embed = discord.Embed(colour=discord.Colour.from_rgb(30, 100, 200))
|
||||
embed = discord.Embed(title=self._title, colour=ghent_university_blue())
|
||||
|
||||
embed.set_author(name=self.course.name)
|
||||
embed.title = self._title
|
||||
|
|
|
@ -47,8 +47,7 @@ class Definition(EmbedPydantic):
|
|||
|
||||
@overrides
|
||||
def to_embed(self, **kwargs: dict) -> discord.Embed:
|
||||
embed = discord.Embed(colour=colours.urban_dictionary_green())
|
||||
embed.set_author(name="Urban Dictionary")
|
||||
embed = discord.Embed(title="Urban Dictionary", colour=colours.urban_dictionary_green())
|
||||
|
||||
embed.add_field(name="Term", value=self.word, inline=True)
|
||||
embed.add_field(name="Author", value=self.author, inline=True)
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
import discord
|
||||
|
||||
__all__ = ["urban_dictionary_green"]
|
||||
__all__ = ["ghent_university_blue", "ghent_university_yellow", "urban_dictionary_green"]
|
||||
|
||||
|
||||
def ghent_university_blue() -> discord.Colour:
|
||||
return discord.Colour.from_rgb(30, 100, 200)
|
||||
|
||||
|
||||
def ghent_university_yellow() -> discord.Colour:
|
||||
return discord.Colour.from_rgb(255, 210, 0)
|
||||
|
||||
|
||||
def urban_dictionary_green() -> discord.Colour:
|
||||
|
|
Loading…
Reference in New Issue