chore: fix the look of randomfunfact.py

This commit is contained in:
neoarz
2025-09-15 07:12:38 -04:00
parent 61420f0e09
commit 8a64a9bc75
2 changed files with 10 additions and 17 deletions

View File

@@ -1,11 +1,3 @@
"""
Copyright © Krypton 2019-Present - https://github.com/kkrypt0nn (https://krypton.ninja)
Description:
🐍 A simple template to start to code your own and personalized Discord bot in Python
Version: 6.4.0
"""
import aiohttp
import discord
from discord.ext import commands
@@ -18,26 +10,27 @@ class RandomFact(commands.Cog, name="randomfact"):
@commands.hybrid_command(name="randomfact", description="Get a random fact.")
async def randomfact(self, context: Context) -> None:
"""
Get a random fact.
:param context: The hybrid command context.
"""
async with aiohttp.ClientSession() as session:
async with session.get(
"https://uselessfacts.jsph.pl/random.json?language=en"
) as request:
if request.status == 200:
data = await request.json()
embed = discord.Embed(description=data["text"], color=0xD75BF4)
embed = discord.Embed(
title="Random Fact",
description=data["text"],
color=0x7289DA
)
embed.set_author(name="Fun", icon_url="https://yes.nighty.works/raw/eW5lLm.webp")
else:
embed = discord.Embed(
title="Error!",
description="There is something wrong with the API, please try again later",
color=0xE02B2B,
)
embed.set_author(name="Fun", icon_url="https://yes.nighty.works/raw/eW5lLm.webp")
await context.send(embed=embed)
async def setup(bot) -> None:
await bot.add_cog(RandomFact(bot))
await bot.add_cog(RandomFact(bot))