Skip to content

Commit

Permalink
v0.1.7-b
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamziee committed Mar 8, 2024
1 parent 78c2b75 commit fe1989e
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,3 @@
# ██║░╚███║╚█████╔╝░░░██║░░░  ██████╔╝╚█████╔╝██║░╚███║███████╗  ░░░██║░░░███████╗░░░██║░░░
# ╚═╝░░╚══╝░╚════╝░░░░╚═╝░░░  ╚═════╝░░╚════╝░╚═╝░░╚══╝╚══════╝  ░░░╚═╝░░░╚══════╝░░░╚═╝░░░


import discord
from discord.ext import commands
from discord import app_commands
import time

class ping(commands.Cog):
def __init__(self, client: commands.Bot):
self.client = client

@app_commands.command(name="embed", description="Send an embed message.")
@app_commands.rename(title='title')
@app_commands.describe(title='Specify the title of the embed.')
@app_commands.rename(description='description')
@app_commands.describe(description='Specify the description of the embed.')
@app_commands.describe(color='Specify the color of the embed.')
@app_commands.choices(fruits=[
Choice(name='blue', value=1),
Choice(name='banana', value=2),
Choice(name='cherry', value=3),
])
async def ping(self, interaction: discord.Interaction, e_title: str, e_description: str):
try:
start = time.time()
embed = discord.Embed(
color=discord.Colour.blurple(),
title=e_title,
description=e_description)
await interaction.response.send_message(embed=embed)
except Exception as e:
print(e)
await interaction.followup.send(content='Error occured.')

async def setup(client:commands.Bot) -> None:
await client.add_cog(ping(client))
88 changes: 88 additions & 0 deletions commands/embed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import discord
from discord.ext import commands
from discord import app_commands

class embed(commands.Cog):
def __init__(self, client: commands.Bot):
self.client = client

@app_commands.command(name="embed", description="Send an embed message.")
@app_commands.rename(title='title')
@app_commands.describe(title='Specify the title of the embed.')
@app_commands.rename(description='description')
@app_commands.describe(description='Specify the description of the embed.')
@app_commands.choices(color=[
discord.app_commands.Choice(name='Aqua', value=2),
discord.app_commands.Choice(name='Dark Aqua', value=3),
discord.app_commands.Choice(name='Green', value=4),
discord.app_commands.Choice(name='Dark Green', value=5),
discord.app_commands.Choice(name='Blue', value=6),
discord.app_commands.Choice(name='Dark Blue', value=7),
discord.app_commands.Choice(name='Purple', value=8),
discord.app_commands.Choice(name='Dark Purple', value=9),
discord.app_commands.Choice(name='Luminous Vivid Pink', value=10),
discord.app_commands.Choice(name='Dark Vivid Pink', value=11),
discord.app_commands.Choice(name='Gold', value=12),
discord.app_commands.Choice(name='Dark Gold', value=13),
discord.app_commands.Choice(name='Orange', value=14),
discord.app_commands.Choice(name='Dark Orange', value=15),
discord.app_commands.Choice(name='Red', value=16),
discord.app_commands.Choice(name='Dark Red', value=17),
discord.app_commands.Choice(name='Grey', value=18),
discord.app_commands.Choice(name='Greyple', value=1),
discord.app_commands.Choice(name='Dark Grey', value=19),
discord.app_commands.Choice(name='Darker Grey', value=20),
discord.app_commands.Choice(name='Light Grey', value=21),
discord.app_commands.Choice(name='Navy', value=22),
discord.app_commands.Choice(name='Dark Navy', value=23),
discord.app_commands.Choice(name='Yellow', value=24)
])
async def embed(self, interaction: discord.Interaction, title: str, description: str, color: discord.app_commands.Choice[int]):
color_mapping = {
'Aqua': (26, 188, 156),
'Dark Aqua': (17, 128, 106),
'Green': (87, 242, 135),
'Dark Green': (31, 139, 76),
'Blue': (52, 152, 219),
'Dark Blue': (32, 102, 147),
'Purple': (155, 89, 182),
'Dark Purple': (113, 54, 138),
'Luminous Vivid Pink': (233, 30, 99),
'Dark Vivid Pink': (173, 20, 87),
'Gold': (241, 196, 15),
'Dark Gold': (194, 124, 14),
'Orange': (230, 126, 34),
'Dark Orange': (168, 67, 0),
'Red': (237, 66, 69),
'Dark Red': (153, 45, 34),
'Grey': (149, 165, 166),
'Dark Grey': (151, 156, 159),
'Darker Grey': (127, 140, 141),
'Light Grey': (188, 192, 192),
'Navy': (52, 73, 94),
'Dark Navy': (44, 62, 80),
'Yellow': (255, 255, 0)
}

def rgb_to_discord_colour(rgb):
return discord.Colour.from_rgb(*rgb)

if color.name in color_mapping:
embed_color = rgb_to_discord_colour(color_mapping[color.name])
else:
# Default color if the color name is not found
embed_color = discord.Colour.blurple()

try:
embed = discord.Embed(
color=embed_color,
title=title,
description=description)
await interaction.response.send_message(content='Embed created, deleting in 5 seconds...', ephemeral=True, delete_after=5)
await interaction.channel.send(embed=embed)
except Exception as e:
print(e)
await interaction.response.send_message(content='Error occured.')

async def setup(client:commands.Bot) -> None:
await client.add_cog(embed(client))
2 changes: 1 addition & 1 deletion ex_config (change me to config.py).py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MIA_VERSION='v0.1.6-b' # Do not change this, it will help with troubleshooting later
MIA_VERSION='v0.1.7-b' # Do not change this, it will help with troubleshooting later

PREFIX = '$' # deprecated, only used for admin and music commands.
OWNER_ID = 496673945211240462 # used for admin commands and ChatAI recognition.
Expand Down
8 changes: 7 additions & 1 deletion mia.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
from colorama import Back, Fore, Style
import time
import platform
import config
try:
import config
# test = config.COMMANDS_DIRECTORY
# print("Commands directory:" + test)
except:
print(Fore.RED + Style.BRIGHT + "Config file could not be found, please refer to the setup instructions in the readme.md file!" + Fore.RESET)
exit()
import os

class Client(commands.Bot):
Expand Down
1 change: 0 additions & 1 deletion todo.txt
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
add make embeds command

0 comments on commit fe1989e

Please sign in to comment.