mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 03:40:11 +01:00
chore: fix the look of randomfunfact.py
This commit is contained in:
@@ -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))
|
||||
Reference in New Issue
Block a user