2026-01-25 06:57:18 +00:00
|
|
|
import discord
|
|
|
|
|
from discord import app_commands
|
|
|
|
|
from discord.ext import commands
|
|
|
|
|
import random
|
|
|
|
|
import aiohttp
|
|
|
|
|
|
|
|
|
|
class Fun(commands.Cog):
|
|
|
|
|
def __init__(self, bot):
|
|
|
|
|
self.bot = bot
|
|
|
|
|
|
|
|
|
|
@app_commands.command(name='8ball', description='Ask the magic 8ball a question')
|
|
|
|
|
async def eightball(self, interaction: discord.Interaction, question: str):
|
|
|
|
|
responses = [
|
|
|
|
|
'Yes, definitely!', 'It is certain.', 'Without a doubt.', 'You may rely on it.',
|
|
|
|
|
'As I see it, yes.', 'Most likely.', 'Outlook good.', 'Signs point to yes.',
|
|
|
|
|
'Reply hazy, try again.', 'Ask again later.', 'Better not tell you now.',
|
|
|
|
|
'Cannot predict now.', "Don't count on it.", 'My reply is no.', 'Very doubtful.'
|
|
|
|
|
]
|
2026-01-28 03:30:24 +00:00
|
|
|
await interaction.response.send_message(f' **{question}**\n{random.choice(responses)}')
|
2026-01-25 06:57:18 +00:00
|
|
|
|
|
|
|
|
@app_commands.command(name='roll', description='Roll a dice')
|
|
|
|
|
async def roll(self, interaction: discord.Interaction, sides: int = 6):
|
|
|
|
|
if sides < 2 or sides > 100:
|
2026-01-28 03:30:24 +00:00
|
|
|
await interaction.response.send_message('Dice must have between 2 and 100 sides!', ephemeral=True)
|
2026-01-25 06:57:18 +00:00
|
|
|
return
|
|
|
|
|
result = random.randint(1, sides)
|
2026-01-28 03:30:24 +00:00
|
|
|
await interaction.response.send_message(f' You rolled a **{result}** (1-{sides})')
|
2026-01-25 06:57:18 +00:00
|
|
|
|
|
|
|
|
@app_commands.command(name='flip', description='Flip a coin')
|
|
|
|
|
async def flip(self, interaction: discord.Interaction):
|
|
|
|
|
result = random.choice(['Heads', 'Tails'])
|
2026-01-28 03:30:24 +00:00
|
|
|
await interaction.response.send_message(f'The coin landed on **{result}**!')
|
2026-01-25 06:57:18 +00:00
|
|
|
|
|
|
|
|
@app_commands.command(name='cat', description='Get a random cat picture')
|
|
|
|
|
async def cat(self, interaction: discord.Interaction):
|
|
|
|
|
await interaction.response.defer()
|
|
|
|
|
async with aiohttp.ClientSession() as session:
|
|
|
|
|
try:
|
|
|
|
|
async with session.get('https://api.thecatapi.com/v1/images/search') as resp:
|
|
|
|
|
data = await resp.json()
|
2026-01-28 03:30:24 +00:00
|
|
|
embed = discord.Embed(title='Random Kitty!', color=0xFF69B4)
|
2026-01-25 06:57:18 +00:00
|
|
|
embed.set_image(url=data[0]['url'])
|
|
|
|
|
embed.set_footer(text=f'Requested by {interaction.user.name}')
|
|
|
|
|
await interaction.followup.send(embed=embed)
|
|
|
|
|
except:
|
2026-01-28 03:30:24 +00:00
|
|
|
await interaction.followup.send('Failed to fetch a cat picture ')
|
2026-01-25 06:57:18 +00:00
|
|
|
|
|
|
|
|
@app_commands.command(name='dog', description='Get a random dog picture')
|
|
|
|
|
async def dog(self, interaction: discord.Interaction):
|
|
|
|
|
await interaction.response.defer()
|
|
|
|
|
async with aiohttp.ClientSession() as session:
|
|
|
|
|
try:
|
|
|
|
|
async with session.get('https://api.thedogapi.com/v1/images/search') as resp:
|
|
|
|
|
data = await resp.json()
|
2026-01-28 03:30:24 +00:00
|
|
|
embed = discord.Embed(title='Random Doggy!', color=0xFF69B4)
|
2026-01-25 06:57:18 +00:00
|
|
|
embed.set_image(url=data[0]['url'])
|
|
|
|
|
embed.set_footer(text=f'Requested by {interaction.user.name}')
|
|
|
|
|
await interaction.followup.send(embed=embed)
|
|
|
|
|
except:
|
2026-01-28 03:30:24 +00:00
|
|
|
await interaction.followup.send('Failed to fetch a dog picture ')
|
2026-01-25 06:57:18 +00:00
|
|
|
|
|
|
|
|
async def setup(bot):
|
|
|
|
|
await bot.add_cog(Fun(bot))
|