0% found this document useful (0 votes)
18 views3 pages

Fun Py

The document defines a Discord bot cog named 'Fun' that includes various fun commands such as coin flip, roast, quote, joke, and GIF actions like kiss, hug, and slap. Each command has a cooldown period and provides interactive responses using emojis and random selections from predefined lists. The cog also includes functionality to fetch GIFs from an external API and display user avatars.

Uploaded by

arpitranjan4958
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views3 pages

Fun Py

The document defines a Discord bot cog named 'Fun' that includes various fun commands such as coin flip, roast, quote, joke, and GIF actions like kiss, hug, and slap. Each command has a cooldown period and provides interactive responses using emojis and random selections from predefined lists. The cog also includes functionality to fetch GIFs from an external API and display user avatars.

Uploaded by

arpitranjan4958
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import discord

import random
import requests
from discord.ext import commands
from emojis import EMOJI_TICK, EMOJI_CROSS, EMOJI_INFO, EMOJI_COINFLIP,
EMOJI_ROAST, EMOJI_JOKE, EMOJI_FACT, EMOJI_KISS, EMOJI_HUG, EMOJI_SLAP, EMOJI_CUD>

class Fun(commands.Cog):
def __init__(self, bot):
self.bot = bot

@commands.command()
@commands.cooldown(1, 5, commands.BucketType.user)
async def coinflip(self, ctx):
"""Flips a coin and shows the result."""
outcome = random.choice(["Heads", "Tails"])
await ctx.send(f"{EMOJI_COINFLIP} The coin landed on **{outcome}**!")

@commands.command()
@commands.cooldown(1, 5, commands.BucketType.user)
async def roast(self, ctx, member: discord.Member):
"""Roasts a user with a funny message."""
roasts = [
f"{member.mention}, tere jaise logon ke liye 'Ctrl+Z' hona chahiye!",
f"{member.mention}, tera dimaag itna tez hai ki Google bhi search karne
lagta hai!",
f"{member.mention}, tu school mein padha hai ya YouTube tutorials se
sikha hai?",
f"{member.mention}, agar bewakoofi ki competition hoti toh tu first bhi
nahi aata... disqualify ho jata!",
f"{member.mention}, teri logic toh Windows XP se bhi slow hai!",
]
await ctx.send(f"{EMOJI_ROAST} {random.choice(roasts)}")

@commands.command()
@commands.cooldown(1, 5, commands.BucketType.user)
async def quote(self, ctx):
"""Sends a random inspirational quote."""
quotes = [
"Sapne woh nahi jo hum sote waqt dekhte hain, sapne woh hain jo hume
sone nahi dete. - APJ Abdul Kalam",
"Zindagi jeene ke do tareeke hote hain, ek jo ho raha hai hone do, ya
zimmedari uthao use badalne ki. - Bhagavad Gita",
"Jab tak tum haar nahi maante, tab tak tum haare nahi ho. - Sachin
Tendulkar",
]
await ctx.send(f"{EMOJI_INFO} {random.choice(quotes)}")

@commands.command()
@commands.cooldown(1, 5, commands.BucketType.user)
async def joke(self, ctx):
"""Sends a random joke."""
jokes = [
"Pappu: Doctor sahab, mujhe aise lagta hai ki mai invisible hu! Doctor:
Kaun bol raha hai?",
"Ek ladka ladki ke piche bhaag raha tha, logon ne poocha kyun? Bola:
'Maths ka question hai, solve karna hai!'",
]
await ctx.send(f"{EMOJI_JOKE} {random.choice(jokes)}")
@commands.command()
@commands.cooldown(1, 5, commands.BucketType.user)
async def fact(self, ctx):
"""Sends a random fun fact."""
facts = [
"Kya aap jaante hain? Shah Jahan ne Taj Mahal banana start karwane se
pehle ek aur Taj Mahal banaya tha... Par woh drawing paper pe tha!",
"Ek normal insaan ek din mein 35,000 decisions leta hai, par jab
biryani saamne ho toh decision lene mein 10 minute lag jaate hain!",
]
await ctx.send(f"{EMOJI_FACT} {random.choice(facts)}")

def get_gif(self, endpoint):


"""Fetches a GIF from the Nekos.life API."""
url = f"https://nekos.life/api/v2/img/{endpoint}"
try:
response = requests.get(url, timeout=5)
response.raise_for_status()
return response.json().get("url")
except requests.RequestException as e:
print(f"Error fetching GIF: {e}")
return None

async def send_gif(self, ctx, action, message):


"""Sends a GIF with a message."""
gif_url = self.get_gif(action)
if gif_url:
embed = discord.Embed(description=message, color=random.randint(0,
0xFFFFFF))
embed.set_image(url=gif_url)
await ctx.send(embed=embed)
else:
await ctx.send(f"{EMOJI_CROSS} GIF not found, try again later.")

@commands.command()
@commands.cooldown(1, 5, commands.BucketType.user)
async def kiss(self, ctx, member: discord.Member):
"""Sends a kiss GIF."""
await self.send_gif(ctx, "kiss", f"{ctx.author.mention} ne {member.mention}
ko ek pyara sa pappi diya! 😘")

@commands.command()
@commands.cooldown(1, 5, commands.BucketType.user)
async def spank(self, ctx, member: discord.Member):
"""Sends a spank GIF."""
await self.send_gif(ctx, "spank", f"{ctx.author.mention} ne
{member.mention} ko zor ka thappad maara! 😆")

@commands.command()
@commands.cooldown(1, 5, commands.BucketType.user)
async def tickle(self, ctx, member: discord.Member):
"""Sends a tickle GIF."""
await self.send_gif(ctx, "tickle", f"{ctx.author.mention} ne
{member.mention} ko gudgudi ki! 🤣")

@commands.command()
@commands.cooldown(1, 5, commands.BucketType.user)
async def slap(self, ctx, member: discord.Member):
"""Sends a slap GIF."""
await self.send_gif(ctx, "slap", f"{ctx.author.mention} ne {member.mention}
ko zor se thappad maara! 😠")

@commands.command()
@commands.cooldown(1, 5, commands.BucketType.user)
async def hug(self, ctx, member: discord.Member):
"""Sends a hug GIF."""
await self.send_gif(ctx, "hug", f"{ctx.author.mention} ne {member.mention}
ko ek garam-garam jhappi di! 🤗")

@commands.command()
@commands.cooldown(1, 5, commands.BucketType.user)
async def cuddle(self, ctx, member: discord.Member):
"""Sends a cuddle GIF."""
await self.send_gif(ctx, "cuddle", f"{ctx.author.mention} ne
{member.mention} ko ek pyara cuddle diya! 🥰")

@commands.command()
@commands.cooldown(1, 5, commands.BucketType.user)
async def avatar(self, ctx, member: discord.Member = None):
"""Displays a user's avatar."""
member = member or ctx.author
embed = discord.Embed(title=f"{member.name}'s Avatar",
color=random.randint(0, 0xFFFFFF))
embed.set_image(url=member.avatar.url)
await ctx.send(embed=embed)

async def setup(bot):


await bot.add_cog(Fun(bot))

You might also like