Files
contest-assistant/bot/helpers.py
Xevion 8164d528a5 Used Embeds in all messages sent
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.
2021-02-18 05:11:06 -06:00

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)