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

@@ -8,14 +8,14 @@ class Choice(discord.ui.View):
super().__init__() super().__init__()
self.value = None self.value = None
@discord.ui.button(label="Heads", style=discord.ButtonStyle.blurple) @discord.ui.button(label="Heads", style=discord.ButtonStyle.primary)
async def confirm( async def confirm(
self, interaction: discord.Interaction, button: discord.ui.Button self, interaction: discord.Interaction, button: discord.ui.Button
) -> None: ) -> None:
self.value = "heads" self.value = "heads"
self.stop() self.stop()
@discord.ui.button(label="Tails", style=discord.ButtonStyle.red) @discord.ui.button(label="Tails", style=discord.ButtonStyle.primary)
async def cancel( async def cancel(
self, interaction: discord.Interaction, button: discord.ui.Button self, interaction: discord.Interaction, button: discord.ui.Button
) -> None: ) -> None:

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 aiohttp
import discord import discord
from discord.ext import commands from discord.ext import commands
@@ -18,24 +10,25 @@ class RandomFact(commands.Cog, name="randomfact"):
@commands.hybrid_command(name="randomfact", description="Get a random fact.") @commands.hybrid_command(name="randomfact", description="Get a random fact.")
async def randomfact(self, context: Context) -> None: 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 aiohttp.ClientSession() as session:
async with session.get( async with session.get(
"https://uselessfacts.jsph.pl/random.json?language=en" "https://uselessfacts.jsph.pl/random.json?language=en"
) as request: ) as request:
if request.status == 200: if request.status == 200:
data = await request.json() 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: else:
embed = discord.Embed( embed = discord.Embed(
title="Error!", title="Error!",
description="There is something wrong with the API, please try again later", description="There is something wrong with the API, please try again later",
color=0xE02B2B, color=0xE02B2B,
) )
embed.set_author(name="Fun", icon_url="https://yes.nighty.works/raw/eW5lLm.webp")
await context.send(embed=embed) await context.send(embed=embed)