Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions framework/isobot/embedengine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""The library used for designing and outputting Discord embeds."""
import discord
from discord import Color


def embed(title: str, desc: str, *, image: str = None, thumbnail: str = None, color:int=None, footer_text: str = None, footer_img: str = None):
"""Designs a Discord embed.
-----------------------------------------------------------
The color argument is completely optional.
- If a color is set, it will return the embed in that color only.
- If the color is set as "rand", then it will return the embed with a random color.
- If a color is not set, it will appear as Discord's blurple embed color.
"""
if color == -1: color = Color.random()
elif color == None: color = Color.blurple()
local_embed = discord.Embed(
title=title,
description=desc,
colour=color
)
if image is not None: local_embed.set_image(url=image)
if thumbnail is not None: local_embed.set_thumbnail(url=thumbnail)
if footer_text is not None and footer_img is not None: local_embed.set_footer(text=footer_text, icon_url=footer_img)
elif footer_text is not None: local_embed.set_footer(text=footer_text)
elif footer_img is not None: local_embed.set_footer(icon_url=footer_img)
return local_embed
18 changes: 18 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import framework.isobot.colors
import framework.isobank.authorize
import framework.isobank.manager
import framework.isobot.embedengine
import discord
from discord.ext import commands, tasks
from discord.ext.commands import *
Expand Down Expand Up @@ -993,6 +994,23 @@ async def repo(ctx:SlashContext):
localembed = discord.Embed(title="Source-code Repositories", description="See and contribute to **isobot lazer's [GitHub repository](https://github.com/PyBotDevs/isobot-lazer)**\nSee our **[GitHub organization](https://github.com/PyBotDevs)**", color=discord.Color.random())
await ctx.send(embed=localembed)

@slash.slash(
name="embedbuilder",
description="Builds a custom embed however you want",
options=[
create_option(name="title", description="The title of the embed", option_type=3, required=True),
create_option(name="description", description="The body of the embed", option_type=3, required=True),
create_option(name="image_url", description="The main image you want to show for the embed (URL ONLY)", option_type=3, required=False),
create_option(name="thumbnail_url", description="The thumbnail image you want to show for the embed (URL ONLY)", option_type=3, required=False),
create_option(name="color", description="The embed's accent color (Use -1 for random color)", option_type=4, required=False),
create_option(name="footer_text", description="The text at the footer of the embed", option_type=3, required=False),
create_option(name="footer_icon_url", description="The icon you want to show in the embed (URL ONLY)", option_type=3, required=False)
]
)
async def embedbuilder(ctx:SlashContext, title: str, description: str, image_url: str = None, thumbnail_url: str = None, color: int = None, footer_text: str = None, footer_icon_url: str = None):
await ctx.send("Embed Built!", hidden=True)
await ctx.channel.send(embed=framework.isobot.embedengine.embed(title, description, image=image_url, thumbnail=thumbnail_url, color=color, footer_text=footer_text, footer_img=footer_icon_url))

@slash.slash(
name="isobank_register",
description="Registers a new IsoBank account with your Discord ID",
Expand Down