mirror of
https://github.com/Xevion/contest-assistant.git
synced 2025-12-12 07:09:36 -06:00
Additionally, helper methods and new constants for Embed colors have been added to simplify this process of sending messages with embeds. Colors have been chosen, too. Extra: The ContestCommandsCog has been given a name kwarg for the 'help' command to display it better.
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
import datetime
|
|
from typing import Union
|
|
|
|
import discord
|
|
|
|
from bot import constants
|
|
|
|
|
|
def is_upvote(emoji: Union[discord.Emoji, discord.PartialEmoji, str]) -> bool:
|
|
"""Helper function for checking if the emoji returned is the upvote emoji the bot looks for."""
|
|
if isinstance(emoji, (discord.Emoji, discord.PartialEmoji)):
|
|
if emoji.id == constants.Emoji.UPVOTE:
|
|
return True
|
|
return False
|
|
|
|
|
|
def general_embed(title: str = '', message: str = '', color: discord.Color = constants.GENERAL_COLOR, timestamp: bool = False) -> discord.Embed:
|
|
"""A generic mostly unstyled embed with a blue color."""
|
|
return discord.Embed(title=title, description=message, timestamp=datetime.datetime.utcnow() if timestamp else discord.Embed.Empty, color=color)
|
|
|
|
|
|
def error_embed(*args, **kwargs):
|
|
"""A generic embed with a light red color."""
|
|
kwargs['color'] = constants.ERROR_COLOR
|
|
return general_embed(*args, **kwargs)
|
|
|
|
|
|
def success_embed(*args, **kwargs):
|
|
"""A generic embed with a light green color."""
|
|
kwargs['color'] = constants.SUCCESS_COLOR
|
|
return general_embed(*args, **kwargs)
|